比较日期以及ActiveRecord查询中的其他约束

时间:2016-06-16 02:16:11

标签: ruby-on-rails postgresql activerecord

我试图获取大于另一个日期的空间列表日期。

到目前为止,我有......

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

我需要检查预订潜在日期是否大于每个space_listing with move_out date。

我的move_out和move_in是一个日期时间。

1 个答案:

答案 0 :(得分:2)

为了在ActiveRecord查询中组合多个约束,您只需使用多个where子句。

Booking.where(space_listing_id: 22, approved_status: true).where("move_out < ?", potential_move_in)