Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 通过比较ActiveRecord中同一记录上的日期来查找记录_Ruby On Rails 3_Activerecord - Fatal编程技术网

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)