解决方法
鉴于您的问题中没有太多细节,我将假设您指的是ActiveRecord对象.要在所谓的“脏对象”上查看已更改的属性,您可以执行以下操作:
http://ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-dirty-objects
User.changed #=> ["name","email"] User.changes #=> { "name" => ["Joe","Joseph"] }@H_403_8@如果需要检查特定属性,还有每个属性的方法.
User.name_changed? #=> true User.name_change #=> ["Joe","Joseph"]@H_403_8@更多细节在这里:
http://ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-dirty-objects