0

我有以下代码行,在本地运行良好,但在推送到生产(Heroku)时会中断:

def self.find_unresolved_with_approved_client
  self.joins(:client).where('clients.approved = true AND wish.status <> "Resolved"')
end

我的heroku日志中的错误如下:

2012-04-09T11:49:14+00:00 app[web.1]: ActionView::Template::Error (PGError: ERROR:  column "Resolved" does not exist
2012-04-09T11:49:14+00:00 app[web.1]:     16:       %th{ :class => :span10 } Subject
2012-04-09T11:49:14+00:00 app[web.1]:     17:       %th{ :class => :span4 } Status
2012-04-09T11:49:14+00:00 app[web.1]: LINE 1: ...ERE (clients.approved = true AND wishes.status != "Resolved"...
2012-04-09T11:49:14+00:00 app[web.1]: : SELECT  "wishes".* FROM "wishes" INNER JOIN "clients" ON "clients"."id" = "wishes"."client_id" WHERE (clients.approved = true AND wishes.status != "Resolved") ORDER BY wishes.id LIMIT 25 OFFSET 0):

当它在本地进行文字比较时,为什么要尝试在 Production 上进行列比较?

4

1 回答 1

2

您应该将查询更改为 .where('clients.approved = ? AND wish.status != ?', true, 'Resolved') 这让适配器为您构建查询,这应该可以解决不同数据库存在的问题查询语法略有不同

于 2012-04-09T12:27:53.410 回答