mardi 23 octobre 2018

Ruby Nested transaction: will nested transaction roll back if outside transaction is rolled back?

model1.rb
def method1
   Model1.transaction do
      model2_ref_obj = Model2.find(some_id)
      model2_ref_obj.method1
  end
end


model2.rb
def method1
   Model2.transaction do
   ## so some work
   self.save!
   end
end

However, due to some issue, model1's transaction rollback, will inner transaction will also roll-back.

Aucun commentaire:

Enregistrer un commentaire