When submitting a master/detail form I first want to handle the children
before saving the parent.
There are has_many and belongs_to relations between the parent and the
children, so I can edit the children using (psuedo-)code like:
child.destroy for deleting, child.update_attributes for updating and
@parent.children.push(child) for adding child-records.
I update the parent by using:
flash[:notice] = ‘Parent was successfully updated.’
redirect_to(:action => “list”)
render :action => ‘edit’
end # if
The problem I’m facing at the moment is that when updating the parent
fails, the chances made to the children are still saved. I tried to
include the code in a transaction:
but this makes no difference.
What am I doing wrong? Hope someone can help me out on this.
Thanks in advance,