instance method
current_transaction
Ruby on Rails 8.1.2
Since v7.2.3Signature
current_transaction()
Returns a representation of the current transaction state, which can be a top level transaction, a savepoint, or the absence of a transaction.
An object is always returned, whether or not a transaction is currently active. To check if a transaction was opened, use current_transaction.open?.
See the ActiveRecord::Transaction documentation for detailed behavior.
Source
# File activerecord/lib/active_record/transactions.rb, line 264
def current_transaction
connection_pool.active_connection&.current_transaction&.user_transaction || Transaction::NULL_TRANSACTION
end
Defined in activerecord/lib/active_record/transactions.rb line 264
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Transactions::ClassMethods