我在 Heroku 上收到此错误,但不是在本地(在两者上都使用 PostgreSQL)..
错误是:
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 上?我如何解决它 ?