Ruby on rails 3 通过比较ActiveRecord中同一记录上的日期来查找记录
假设我有一个带有三个日期字段的模型:Ruby on rails 3 通过比较ActiveRecord中同一记录上的日期来查找记录,ruby-on-rails-3,activerecord,Ruby On Rails 3,Activerecord,假设我有一个带有三个日期字段的模型: 在 更新时间 xyz_at 我如何查找所有记录,其中xyz\u atupdated\u at?records=YourModel.where('xyz\u at
在
更新时间
xyz_at
xyz\u at
updated\u at
?records=YourModel.where('xyz\u atrecords = YourModel.where('xyz_at < updated_at')
for record in records
puts record.updated_at, record.xyz_at
end
记录在案
将record.updated_置于,将record.xyz_置于
结束
records=YourModel.where('xyz\u at
我正试图这样做,但xyz_最初为零。这不管用。除了使xyz_at默认为过去的某个时间方式之外,还有更好的方法来处理这个问题吗self.xyz|u at | |=Date.new(1979,12,13)
。这不管用。除了使xyz_at默认为过去的某个时间方式之外,还有更好的方法来处理这个问题吗<代码>self.xyz_at | |=Date.new(1979,12,13)