Skip to content

Commit f4f890e

Browse files
committed
Fix example should use class method instead of DatabaseStatements#transaction [ci skip]
Also fixes the alignment of the comments. See: https://edgeapi.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html#module-ActiveRecord::Transactions::ClassMethods-label-Caveats
1 parent c67d91b commit f4f890e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

activerecord/lib/active_record/transactions.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,11 @@ module Transactions
219219
# database error will occur because the savepoint has already been
220220
# automatically released. The following example demonstrates the problem:
221221
#
222-
# Model.lease_connection.transaction do # BEGIN
223-
# Model.lease_connection.transaction(requires_new: true) do # CREATE SAVEPOINT active_record_1
224-
# Model.lease_connection.create_table(...) # active_record_1 now automatically released
225-
# end # RELEASE SAVEPOINT active_record_1
226-
# # ^^^^ BOOM! database error!
227-
# end
222+
# Model.transaction do # BEGIN
223+
# Model.transaction(requires_new: true) do # CREATE SAVEPOINT active_record_1
224+
# Model.lease_connection.create_table(...) # active_record_1 now automatically released
225+
# end # RELEASE SAVEPOINT active_record_1
226+
# end # ^^^^ BOOM! database error!
228227
#
229228
# Note that "TRUNCATE" is also a MySQL DDL statement!
230229
module ClassMethods

0 commit comments

Comments
 (0)