我在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上发生了这种情况?我该如何解决它?