Accessing model attributes before modification

Hi,

in a callback method of one of my Models I want to access its attributes values before they are modified.

I tried both 'before_validation' and 'before_save', unsuccessfully: it looks like that even before the validation get started the attributes are already modified.

Any hints?

Thanks.

Marco

Marco Lazzeri wrote:

in a callback method of one of my Models I want to access its attributes values before they are modified.

I tried both 'before_validation' and 'before_save', unsuccessfully: it looks like that even before the validation get started the attributes are already modified.

You'll have to either save the original values in an after_find method, or make your own version of methods such as update_attributes, giving you access to both the old and new values.

don't know if this will help you but you can try the acts_as_modified plugin and see if it does what you want

http://svn.viney.net.nz/things/rails/plugins/acts_as_modified/