我的模型中有这行代码:
pay_period = TimesheetPayPeriod.find(:first, :conditions => ["start_date <= ? AND end_date >= ?", date.to_date, date.to_date])
我收到此错误:
ActiveRecord :: RecordNotFound(无法找到所有带有'id'的TimesheetPayPeriods :(第一,{:conditions => [“ start_date <=?AND end_date> =?”,2017年3月3日,星期五,2017年3月3日]) )(找到 0 个结果,但正在寻找 2 个)):
这个错误是什么意思,我该如何纠正?
更改查询以使用新语法
pay_period =
TimesheetPayPeriod.where("start_date <= ? AND end_date >= ?", date.to_date, date.to_date).first
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句