Skip to content

Commit 8a3dcf9

Browse files
committed
Add link to Rollback in transactions doc.
A common misconception with transaction rollback in Rails is that exceptions will not be re-raised from nested transactions. This is only true for ActiveRecord::Rollback. The documentation for that class makes that clear. A link to that class doc has been added, as well as an explicit restatement that all other exceptions will be re-raised.
1 parent 7db044f commit 8a3dcf9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

activerecord/lib/active_record/transactions.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ module Transactions
9999
# be propagated (after triggering the ROLLBACK), so you should be ready to
100100
# catch those in your application code.
101101
#
102-
# One exception is the ActiveRecord::Rollback exception, which will trigger
103-
# a ROLLBACK when raised, but not be re-raised by the transaction block.
102+
# One exception is the {ActiveRecord::Rollback}[rdoc-ref:Rollback] exception, which will trigger
103+
# a ROLLBACK when raised, but not be re-raised by the transaction block. Any
104+
# other exception will be re-raised.
104105
#
105106
# *Warning*: one should not catch ActiveRecord::StatementInvalid exceptions
106107
# inside a transaction block. ActiveRecord::StatementInvalid exceptions indicate that an

0 commit comments

Comments
 (0)