instance method current_transaction

Ruby on Rails 8.0.4

Since v7.2.3

Available in: v7.2.3 v8.0.4 v8.1.2

Signature

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 244
      def current_transaction
        connection_pool.active_connection&.current_transaction&.user_transaction || Transaction::NULL_TRANSACTION
      end

Defined in activerecord/lib/active_record/transactions.rb line 244 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Transactions::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close