1
我只是試圖運行查詢來查找數據庫中的所有記錄在「datetime」列中的值小於當前的unix時間戳。活動記錄查詢和heroku問題。
目前這是我的代碼。它在當地運行良好。
t = Time.new.to_i
Event.where("datetime < #{t}")
當我在heroku控制檯中測試這個錯誤時,我得到這個錯誤。
>> Event.where("datetime < #{t}")
ActiveRecord::StatementInvalid: PGError: ERROR: operator does not exist: character varying < integer
LINE 1: SELECT "events".* FROM "events" WHERE (datetime < 132462148...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "events".* FROM "events" WHERE (datetime < 1324621488)
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:1003:in `async_exec'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:1003:in `exec_no_cache'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:591:in `block in exec_query'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'
任何想法?
你在本地使用postgresql嗎? – thatmiddleway 2011-12-23 06:40:19