KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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. Art.all(:order => "created_at desc", :limit => 10, :group => "user_id") ActiveRecord error: 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... Any ideas?
Tags (comma-separated)
Save Edits
Cancel