Heroku (PG :: Error: ERROR: Column must appear in GROUP BY clause or used in aggregate function

I am getting this error on Heroku but not locally (using PostgreSQL for both).

mistake:

ActiveRecord::StatementInvalid (PG::Error: ERROR:  column "posts.content" must appear in the GROUP BY clause or be used in an aggregate function

      

I suspect it has something to do with this line in my message model:

scope :with_tags, lambda { |tags| joins(:tags).group('posts.id').where(:tags => { :id => tags.map { |t| t.id } } ).having("COUNT(*) = ?", tags.length) }

      

why does this only happen on Heroku? how to fix it?

+3


source to share


1 answer


As someone pointed out, this is an issue with Postgres 9.0 that was fixed in Postgres 9.1. On Heroku, you can use the Heroku Shared PostgreSQL addon instead of the standard DB and that should fix the problem.



+1


source







All Articles