目前我有以下行:
scope :within_date_range, ->(start_date, end_date) {
where("(start_date BETWEEN ? AND ?) OR (end_date BETWEEN ? AND ?)", start_date, end_date, start_date, end_date)
}
有没有更优雅的方式使用类似的东西来做到这一点?
scope :within_date_range, ->(start_date, end_date) {
where((:start_date => start_date..end_date) OR (:end_date => start_date..end_date))
}