What''s the best way to examine what fields on a model are changing? Would you use a callback to do that and how? I guess the simplest example of this is how lighthouseapp documents changes that a person makes to a ticket: Milestone changed from “2.x” to “3.0” State changed from “new” to “open” How could I accomplish the same thing?
Take a look at ActiveRecord::Dirty<http://api.rubyonrails.org/classes/ActiveRecord/Dirty.html> -- Benjamin Curtis http://railskits.com/ - Ready-made Rails code http://catchthebest.com/ - Team-powered recruiting http://www.bencurtis.com/ - Personal blog On Wed, May 27, 2009 at 7:25 AM, JL Smith <autiger02-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > What''s the best way to examine what fields on a model are changing? > Would you use a callback to do that and how? > > I guess the simplest example of this is how lighthouseapp documents > changes that a person makes to a ticket: > > Milestone changed from “2.x” to “3.0” > > State changed from “new” to “open” > > How could I accomplish the same thing? > > >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Craig Demyanovich
2009-May-27 14:31 UTC
Re: Use callbacks to determine model field changes?
If you''re on Rails >= 2.1, you can track attribute changes: http://api.rubyonrails.org/classes/ActiveRecord/Dirty.html You might also like Ryan Bates'' screencast on the topic: http://railscasts.com/episodes/109-tracking-attribute-changes Regards, Craig -- Craig Demyanovich Mutually Human Software http://mutuallyhuman.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---