josh.rachner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2009-Apr-16 22:02 UTC
Saving parent record before child
I am on Rails 2.2 and want to save an artist object with a child attribute called artist_mood_concepts. I can update fine but when I do an @artist.save, it gives me an error about saving the parent before the child (which makes perfect sense). What is the easiest way to solve the problem? after_update? Thanks, Josh --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
josh.rachner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I am on Rails 2.2 and want to save an artist object with a child > attribute called artist_mood_concepts. I can update fine but when I > do an @artist.save, it gives me an error about saving the parent > before the child (which makes perfect sense). What is the easiest way > to solve the problem? after_update? > > Thanks, > > JoshSave the child in the before_save method of the parent, maybe? Or if it should be the other way round, do it in after_save. -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---