views:

33

answers:

1

I have an ActivityObserver, which is observing tasks, and has an after_update callback.

I want to test if a particular attribute has been modified in the update.

Is there a Rails way to compare the attributes of the subject with what they were before the update, or to check if they have changed?

+3  A: 

When an after_update callback is being executed, you have an object called @changed_attributes You check it out in your debug environment. Every ActiveRecord object has this object. It has a hash of all the values that have been changed/modified. You can check into it. This is also known as Dirty object.

Check out some of these tutorials

Railscasts

Dirty Object

Rohit
Thanks! No matter how much Rails dev I do, there's always something new to learn.
nfm