Saving parent record before child


#1

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


#2

removed_email_address@domain.invalid 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,

Josh

Save 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.