Skip to content

Commit

Permalink
Add "Nested Transactions" section
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 authored Feb 11, 2024
1 parent 524a1ac commit 91a682c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,28 @@ else
end
----

=== Nested Transactions [[nested-transactions]]

Use `requires_new: true` if you want to avoid nested transactions unintentionally becoming part of the parent transaction.
`joinable: false` is a private API and should not be used. If used, serious side effects may occur, such as `after_commit` not working properly.

[source,ruby]
----
# bad
ActiveRecord::Base.transaction(requires_new: true, joinable: false) do
ActiveRecord::Base.transaction do
# ...
end
end
# good
ActiveRecord::Base.transaction(requires_new: true) do
ActiveRecord::Base.transaction(requires_new: true) do
# ...
end
end
----

== Models: Active Record Queries [[activerecord-queries]]

=== Avoid Interpolation [[avoid-interpolation]]
Expand Down

0 comments on commit 91a682c

Please sign in to comment.