title: PG::Error in GROUP BY clause
body: <p>I couldn't think of a better way to refactor the below code (see <a href="https://stackoverflow.com/questions/16373950/grouping-by-one-column-and-summing-multiple-other-columns-in-rails/16374026?noredirect=1#16374026">this question</a>), though I know it's very ugly. However, it's throwing a Postgres error (not with SQLite):</p>
  
  <pre><code>ActiveRecord::StatementInvalid: 
  PG::Error: ERROR:  
  column "articles.id" must appear in the GROUP BY clause or be used in an aggregate function
  </code></pre>
  
  <p>The query itself is:</p>
  
  <pre><code>SELECT "articles".* 
  FROM "articles" 
  WHERE "articles"."user_id" = 1 
  GROUP BY publication
  </code></pre>
  
  <p>Which comes from the following view code:</p>
  
  <pre><code>=@user.articles.group(:publication).map do |p|
    =p.publication
    =@user.articles.where("publication = ?", p.publication).sum(:twitter_count)
    =@user.articles.where("publication = ?", p.publication).sum(:facebook_count)
    =@user.articles.where("publication = ?", p.publication).sum(:linkedin_count)
  </code></pre>
  
  <p>In SQLite, this gives the output (e.g.) NYT 12 18 14 BBC 45 46 47 CNN 75 54 78, which is pretty much what I need.</p>
  
  <p>How can I improve the code to remove this error?</p>