title: group_by and count
body: <pre><code>@entries_by_source = Entry.joins(:training_entries).group("source_id, classification_id, category_id").select("source_id, classification_id, category_id, count(*) as entries_count")
  </code></pre>
  
  <p>These are in @entires_by_source</p>
  
  <pre><code>- !ruby/ActiveRecord:Entry 
    attributes: 
      source_id: 1
      classification_id: 1
      category_id: 1
      entries_count: 198
  - !ruby/ActiveRecord:Entry 
    attributes: 
      source_id: 1
      classification_id: 1
      category_id: 2
      entries_count: 614
  - !ruby/ActiveRecord:Entry 
    attributes: 
      source_id: 2
      classification_id: 1
      category_id: 3
      entries_count: 1
  </code></pre>
  
  <p>Now i'm trying to print something like that:</p>
  
  <pre><code>source_id entries_count
  1          812 #sum of entries_count 198 + 614
  2          1
  </code></pre>
  
  <p>The code below is not working. Any help will be appreciated</p>
  
  <pre><code>&lt;% @entries_by_source.group_by(&amp;:source_id).each do |source_id, entries_count| %&gt;
    &lt;%= source_id %&gt;&lt;%= entries_count %&gt;
  &lt;% end %&gt;
  </code></pre>