3

我在 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 上?我如何解决它 ?

4

1 回答 1

1

正如有人指出的那样,这是 Postgres 9.0 的一个问题,已在 Postgres 9.1 中修复。在 Heroku 中,您可以使用Heroku Shared PostgreSQL 插件而不是默认数据库,这应该可以解决问题。

于 2012-04-11T05:23:18.663 回答