I have model Car. I set to @cars.update_attributes params as hash(params = {"id"=>"60", "attr_1"=>"137.0", "attr_2"=>"11414.0", "attr_3"=>"6004"}) And after I see in log -
(0.8ms) UPDATE "cars" SET "attr_3" = 6004.0, "updated_at" = '2015-02-27 18:51:52.583925' WHERE "cars"."id" = 60
Only field attr_3 was updated. attr_1 and attr_2 have old values and so even not try update. How I can see attrs which will be updated before "send" commands to DB?
You want the methods provided by ActiveModel::Dirty.
http://api.rubyonrails.org/classes/ActiveModel/Dirty.html
@cars.changes
for example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.