After looking at some previous threads it looks like th best way to do with
is to overwrite the attribute writer in the model like so:
def name=(val)
@old_name = (val == name) ? nil : name
super val
end
And then just checking the @old_val in the callback... I thought that
these accessors were not always used in all the update methods, but after
looking in the docs it appears that they are. If I am mistaken please let
me know. But otherwise, sorry for talking to myself on the mailing list :)
-Ben
On 5/6/07, Ben <benmabey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
>
> Hey all,
> What is the best/easiest way to detect if a certain AR model
> attrirbute has changed in a callback? For example, I have a date
> field in my model that needs to be updated when a certain attribute
> has been changed. What is the best way to do this in a call back?
> Thanks,
> Ben
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---