这在我的开发环境中有效,但是当我尝试通过 Heroku 和 Postgres 运行时,我得到了这个错误。
2012-04-07T21:35:14+00:00 app[web.1]: ActiveRecord::StatementInvalid
(PG::Error: ERROR: operator does not exist: integer == integer
2012-04-07T21:35:14+00:00 app[web.1]: LINE 1: ...."value") AS avg_id FROM "datapoints"
WHERE (habit_id == 1)
2012-04-07T21:35:14+00:00 app[web.1]: HINT: No operator matches the given name and argument type(s).
You might need to add explicit type casts.
2012-04-07T21:35:14+00:00 app[web.1]: : SELECT AVG("datapoints"."value") AS avg_id FROM "datapoints
WHERE (habit_id == 1)):
以下是我的控制器中的代码行:
Datapoint.average(:value, :conditions => ['habit_id == ?', self.habit_id])
我对 Rails 很陌生,所以这很容易成为一个非常简单的错误——对我在这里做错了什么有任何想法吗?