Comparing field's old value to new value

I want to expire caches if a certain field of an item changes. How can I
compare the item field’s
old value to its new value (in the create, or after_save, etc. method)?

thanks
csn


Yahoo! Mail - PC Magazine Editors’ Choice 2005

Hi !

There’s after_find and after_initialize you can use to copy the
values. If you have only one or two fields, just override the field’s
setter methods:

class X < AR:Base
def attribute=(new_value)
old_value ||= read_attribute(:attribute)
write_attribute(:attribute, new_value)
end
end

Untested, and I’m not even sure write|read_attribute are the right
method names. You get the gist, though.

Bye !
François

2005/11/27, CSN [email protected]: