Reputation: 12378
What happens when you have transactions with transactions
def a
ActiveRecord::Base.transaction do
# stuff
end
end
ActiveRecord::Base.transaction do
a
# more stuff
end
What happens if the inner transaction succeeds but the outer fails and vice versa? What happens when both succeed or fail?
Upvotes: 8
Views: 6054
Reputation: 599
You can use nested transaction in rails.But you have to focus on the rollbacking part in case of nested transaction. Check nested-transations-in-rails .
Upvotes: -1
Reputation: 12826
transaction
calls can be nested. By default, this makes all database statements in the nested transaction block become part of the parent transaction.
The behaviour is well described in the documentation
Upvotes: 11