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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2006-Nov-27 16:36 UTC
Re: Accessing model attributes before modification
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. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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/ On 11/27/06, Mark Reginald James <mrj-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> > 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. > > -- > We develop, watch us RoR, in numbers too big to ignore. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---