我得到在Heroku这个错误,但没有在本地(在两个使用PostgreSQL)..的Heroku(PG ::错误:错误:列必须出现在GROUP BY子句或聚合函数中使用
错误是:
ActiveRecord::StatementInvalid (PG::Error: ERROR: column "posts.content" must appear in the GROUP BY clause or be used in an aggregate function
我怀疑它是做这一行我的帖子模式:??
scope :with_tags, lambda { |tags| joins(:tags).group('posts.id').where(:tags => { :id => tags.map { |t| t.id } }).having("COUNT(*) = ?", tags.length) }
为什么只在Heroku上发生怎样解决呢
我不太确定这是为什么我要添加评论,但尝试将post.content与post.id放在.group括号中。 – 2012-04-08 21:17:55
我添加了它,现在它给了另一列上的错误, 必须有一个更好的方法来解决这个问题,而不是手动添加帖子中的所有列.. 也,我仍然想知道为什么它只发生在Heroku而不是本地PG – 2012-04-08 21:32:26
我认为这是postgres 9.1和9.0之间的区别。尝试在heroku上更新您的版本:https://devcenter.heroku.com/articles/upgrading-postgres-versions – 2012-04-08 21:44:03