这适用于我的开发环境,但是当我尝试使用Postgres通过Heroku运行时,我收到此错误.
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)):
Run Code Online (Sandbox Code Playgroud)
以下是我的控制器的代码行:
Datapoint.average(:value, :conditions => ['habit_id == ?', self.habit_id])
Run Code Online (Sandbox Code Playgroud)
我对rails很新,所以这很容易就是一个非常简单的错误 - 对我在这里做错了什么的想法?