title: will paginate with multiple tables
body: <p>I have following tables :</p>
  
  <ol>
  <li>users</li>
  <li>accounts ( user has_one account )</li>
  <li>pictures ( user has_many pictures )</li>
  </ol>
  
  <p>I want to display a User along with its related account and pictures. This is a typical N+1 queries problem and I solved it using <a href="http://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations" rel="nofollow noreferrer">eager loading</a>.</p>
  
  <pre><code>User.includes(:account, :pictures).all
  </code></pre>
  
  <p>I am trying to use <code>will_paginate</code> gem. How do I include this eager loading mechanism into <code>will_paginate</code> ?</p>
  
  <p>I found a similar question here: <a href="https://stackoverflow.com/questions/1091713/using-will-paginate-with-multiple-models-rails">Using will_paginate with multiple models (Rails)</a>. But the links in the answer are out of place and the answer itself is quite old. Furthermore, it uses raw sql queries, which I don't prefer.</p>
  
  <p>I want the output as follows :</p>
  
  <pre><code>user.name account.field1 account.field2 picture.count
  abc1       abcf1          abcf2           4
  zxc        zxcf1          zxcf2           7
  </code></pre>
  
  <p>So basically when I do <code>user.name</code> , it will not execute a query but just get the data from the variables;
  same way when I do <code>user.account.field1</code> it should fetch it from the variable and not execute a query.</p>