i have a transaction to ensure two models get saved at the same time.
begin
Recipe.transaction do
@recipe.save!
if @dish
@dish.save!
end
end
rescue
#save failed
flash[:notice] = "recipe.saved = #{@recipe.new_record?}"
render 'form'
else
#save worked
flash[:notice] = 'Recipe added.'
redirect_to(@recipe)
end
when validation fails for one of the models it goes to the rescue block however in the rescue block it says that the model is not a new record. i was expecting the validation to cause the transaction to fail, thus leaving the model object as a new record? what am i missing here?