title: Rails 3.1 with PostgreSQL: GROUP BY must be used in an aggregate function
body: <p>I am trying to load the latest 10 Arts grouped by the user_id and ordered by created_at. This works fine with SqlLite and MySQL, but gives an error on my new PostgreSQL database.</p>
  
  <pre><code>Art.all(:order =&gt; "created_at desc", :limit =&gt; 10, :group =&gt; "user_id")
  </code></pre>
  
  <p>ActiveRecord error:</p>
  
  <pre><code>Art Load (18.4ms)  SELECT "arts".* FROM "arts" GROUP BY user_id ORDER BY created_at desc LIMIT 10
  ActiveRecord::StatementInvalid: PGError: ERROR:  column "arts.id" must appear in the GROUP BY clause or be used in an aggregate function
  LINE 1: SELECT  "arts".* FROM "arts"  GROUP BY user_id ORDER BY crea...
  </code></pre>
  
  <p>Any ideas?</p>