Jun
04
I had to update some attributes of an object. This can easily be done by my_obj.update_attributes(params). If you want to know the updated attributes …it’s not so easy.
update_attributes internally calls the save-method, so that my_obj.changes can’t be called after update_attributes. My solution was to patch ActiveRecord, so that it additionally returns the changed attributes.
Usage example
status, changes = my_obj.update_attributes_changed(params)
config/initializers/active_record_patch.rb
module ActiveRecord
class Base
def update_attributes_changed(attributes)
self.attributes = attributes
changes = self.changes
return save, changes
end
end
end

At least from Rails 2.3.8 on you can use a after_update filter. Seen here
http://stackoverflow.com/questions/3861777/determine-what-attributes-were-changed-in-rails-after-save-callback/3861875#3861875