我有一个工作人员需要遍历许多模型并将一些数据保存到数据库中。
def perform()
Project.for_each do |project|
project.subprojects.for_each do |ps|
Result.create(ps_id: ps.id)
end
end
end
我得到一个错误:
'“enqueued_at”=&gt; 1381919287.982079,“error_message”=&gt;“未定义方法for_each' for #<Class:0x007fe5c6b14b40>", "error_class"=>"NoMethodError", "failed_at"=>"2013-10-16T10:29:18Z", "retry_count"=>1, "retried_at"=>2013-10-16 10:30:03 UTC}
2013-10-16T10:30:03Z 12893 TID-ox92y34ec WARN: undefined method
for_each”代表#