ActiveRecord Save Dependent Model
I am trying to save a model with its dependency models being saved.
Model1
has_many :model2, :autosave => true
Model2
belongs_to :model1
has_many :model3, :autosave => true
Model3
belongs_to :model2
I want to save Model1, and have Model2 and 3 save as well. I tried this without and with the autosave feature. What winds up happening is Model1 is saved, Model2 is saved, Model3 is untouched. Is there a way to tell ActiveRecord that for this save I want to save the model and all child models all at once?
As a side note, all 3 are just created and are not in the database. I cannot do .create on the models because I cannot save them until all valida开发者_C百科tion passes and all business logic succeeds (has to be a transaction).
Looks like there is no proposed methodology to debug this issue, I will just close it as such.
精彩评论