title: Activerecord group by count and user_id
body: <p>I have two models with has_many associations.</p>
  
  <pre><code>User :has_many foos
  Foo :belongs_to user
  </code></pre>
  
  <p>Foo.joins(:user)</p>
  
  <p>I want to have a group by on Foo, where it returns with count and user_id.
  Means I want to know how many 'foos' with 'user_id'.</p>
  
  <p>Eg:</p>
  
  <pre><code>user_id foos_count 
  -------------
  1     31
  2     52
  </code></pre>