如何获取 date_of_leaving 为零或应该在 rails 中的特定日期范围内的记录?

how to fetch records whose date_of_leaving is nil or it should be in particular range of dates in rails?

我想在 employee 模型上写一个 query,其中 employee date_of_leavingnil 或者它应该在特定的 date range

这是我当前的查询:

e = Employee.where.not('date_of_leaving >= ? and date_of_leaving <= ?', Date.today - 60, Date.today).where(:date_of_leaving => nil)

但它返回 #<ActiveRecord::Relation []>

以下查询将 return 所有 date_of_leaving 在指定日期之间或 nil 的员工:

Employee.where('date_of_leaving BETWEEN ? AND ? OR date_of_leaving IS NULL', Date.today - 60, Date.today)