dan kuwachi
2007-Mar-09 22:34 UTC
in after_update, possible to see previous value of record?
I have this situation where in an after_update, I would like to know the previous value of the record instead of simply being notified the record has been updated. For example let''s say I had a table called ''foo'' which had a field ''new_flag''. I want to know when the ''new_flag'' field changes from 0 --> 1 in an after_update so I can do some business logic in theafter_update. My problem is in the after_update I don''t know how to detect if that particular field got updated. Is there some api call I can use to access the old object? thanks! -dan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
bcparanj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-10 02:04 UTC
Re: in after_update, possible to see previous value of record?
Use the acts_as_versioned plugin http://wiki.rubyonrails.com/rails/pages/ActsAsVersioned. You can use the API that will allow you to call the previous version object and access its values.> > after_update. My problem is in the after_update I don''t know how to > detect if that particular field got updated. > > Is there some api call I can use to access the old object? > > thanks! > -dan--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---