2016-06-16 7 views
1

私は別の日付よりも大きいスペースリストの日付を取得しようとしています。 ActiveRecordクエリの他の制約と日付を比較します

これまでのところ、私が持っている

...

Booking.where({ space_listing_id: 22, approved_status: true, ['move_out < ?', potential_move_in] }) 

は私が予約可能日はmove_out日とspace_listingそれぞれよりも大きいかどうかを確認する必要があります。

私のmove_outとmove_inはdatetimeです。

+1

http://stackoverflow.com/a/4224627/2545197この回答は役に立ちました – Abhinay

+0

ありがとうAbhinay。それは今働いている。私はBooking.where( "move_out <?"、potential_move_in).where({space_listing_id:22、approved_status:true}) –

+1

あなたの質問には別の 'where'クエリーがあります。 – Abhinay

答えて

2

ActiveRecordクエリで複数の制約を組み合わせるには、複数のwhere節を使用するだけです。

Booking.where(space_listing_id: 22, approved_status: true).where("move_out < ?", potential_move_in) 
関連する問題