bradphelan/rocket_tag — pull request #17 by Beans0063 (2012-06-08 11:58:05+00:00)
Title: Postgres fix

I ran into this issue when deploying to Heroku, which runs postgresql.

ActionView::Template::Error (PG::Error: ERROR: column "operators.name" must appear in the GROUP BY clause or be used in an aggregate function
2012-06-08T10:28:28+00:00 app[web.1]: : SELECT * FROM (SELECT count("operators"."id") AS tags_count, operators.* FROM "operators" INNER JOIN "taggings" ON "taggings"."taggable_id" = "operators"."id" AND "taggings"."taggable_type" = 'Operator' INNER JOIN "tags" ON "tags"."id" = "taggings"."tag_id" WHERE "tags"."name" IN ('music') GROUP BY "operators"."id") operators ):

The requirements for group by in aggregate SQL are different than MySQL. All column names must be listed in the group by statement. There is good discussion about it here:

http://stackoverflow.com/questions/1769361/postgresql-group-by-different-from-mysql

Listing the model's column_names in the group by fixes the issue for postgres.