2016-12-15 6 views
0

"終了"フィールドがTime.nowより小さい場合、予約の@レーティングを表示しようとしています。ActiveRecordクエリにインクルードと制限の日付を使用

これは(ただし、時間制限なし)作品:

@ratings = Rating.where(user_id: current_user.id).includes(:reservation).includes(:room) 

私はこのように、 "reservations.end < Time.now" でクエリを制限しようとしています:

@ratings = Rating.where(user_id: current_user.id, reservations.end < Time.now).includes(:reservation).includes(:room) 

それは動作しません。

答えて

2
@ratings = Rating.includes(:reservation, :room).where(user_id: current_user.id).where("reservations.end < ?", Time.now) 
関連する問題