I have a transaction that saves two models at the same time.
begin
Recipe.transaction do
@recipe.save!
if @dish
@dish.save!
end
end
rescue
flash[:notice] = "recipe.saved = #{@recipe.new_record?}"
render 'form'
else
flash[:notice] = 'Recipe added.'
redirect_to(@recipe)
end
when the check is not performed for one of the models that it sends to the rescue unit, however, the disaster recovery unit says that the model is not a new record. Did I expect the validation to fail the transaction, leaving the model object as a new record? What am I missing here?
source
share