rovnak
2007-Apr-14 10:17 UTC
distinguishing "update or create context" from within after_save?
Hi, Of course, I like the callbacks in active record. However, it seems that it would be valuable to be able to distinguish whether an after_save is being invoked as part of a create as opposed to part of an update scenario. Is there a best practice for doing this? I assume I can set a flag int he create or update methods and check in the after_save, but not sure if this is best practice. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ben Munat
2007-Apr-14 18:44 UTC
Re: distinguishing "update or create context" from within after_save?
You mean like using the after_create and after_update callbacks instead? :-) b rovnak wrote:> > Hi, > Of course, I like the callbacks in active record. However, it seems > that it would be valuable to be able to distinguish whether an > after_save is being invoked as part of a create as opposed to part of > an update scenario. > > Is there a best practice for doing this? I assume I can set a flag int > he create or update methods and check in the after_save, but not sure > if this is best practice. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---