Каков наилучший способ написать запрос Rails, который возвращает записи не менее 5 минут? Я использую Rails 3.0.1, Ruby 1.9.2 и PostgreSQL. На данный момент у меня есть это:
Note.order('date DESC').where('private_note = ? AND (?-created_at) > 300',false, Time.now.utc)
, который получает эти ошибки:
Note Load (0.7ms) SELECT "notes".* FROM "notes" WHERE (private_note = 'f' AND ('2011-09-28 01:07:30.094475'-created_at) > 300) ORDER BY date DESC
PGError: ERROR: operator does not exist: interval > integer
LINE 1: ...'f' AND ('2011-09-28 01:07:30.094475'-created_at) > 300) ORD...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "notes".* FROM "notes" WHERE (private_note = 'f' AND ('2011-09-28 01:07:30.094475'-created_at) > 300) ORDER BY date DESC
Completed in 214ms
ActiveRecord::StatementInvalid (PGError: ERROR: operator does not exist: interval > integer
LINE 1: ...'f' AND ('2011-09-28 01:07:30.094475'-created_at) > 300) ORD...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "notes".* FROM "notes" WHERE (private_note = 'f' AND ('2011-09-28 01:07:30.094475'-created_at) > 300) ORDER BY date DESC):
app/controllers/notes_controller.rb:17:in `public_stream_get_notes'
Примером значения созданного_атериала является 2011-09-28 01:00:01 UTC