I couldn\'t think of a better way to refactor the below code (see this question), though I know it\'s very ugly. However, it\'s throwing a Postgres error (not with SQLite):<
Craig's answer explains the issue well. Active Record will select * by default, but you can override it easily:
@user.articles.select("publication, sum(twitter_count) as twitter_count").group(:publication).each do |row|
p row.publication # "BBC"
p row.twitter_count # 45
end