Rails 3 で次の検索を実行します:
Note.where(:user_id => current_user.id, :notetype => p[:note_type], :date => p[:date]).order('date ASC, created_at ASC')
:date => p[:date]
しかし、条件が と同等である必要があります:date > p[:date]
。どうすればいいでしょうか? 読んでくれてありがとう。
ベストアンサー1
Note.
where(:user_id => current_user.id, :notetype => p[:note_type]).
where("date > ?", p[:date]).
order('date ASC, created_at ASC')
あるいはすべてをSQL表記に変換することもできます
Note.
where("user_id = ? AND notetype = ? AND date > ?", current_user.id, p[:note_type], p[:date]).
order('date ASC, created_at ASC')