I want to fetch only changed attributes of an object. Is there any method available which returns all the updated attributes?
Given there aren't many specifics in your question, I'm going to assume you're referring to ActiveRecord objects. To view the changed attributes on so called "Dirty Objects" you can do the following:
User.changed #=> ["name", "email"]
User.changes #=> { "name" => ["Joe", "Joseph"] }
There are also methods for each attribute if you need to check specific ones.
User.name_changed? #=> true
User.name_change #=> ["Joe", "Joseph"]
More details here: http://ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-dirty-objects
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With