instance method rollback_active_record_state!

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v4.1.16

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16

Signature

rollback_active_record_state!()

Reset id and @new_record if the transaction rolls back.

Source
# File activerecord/lib/active_record/transactions.rb, line 204
    def rollback_active_record_state!
      id_present = has_attribute?(self.class.primary_key)
      previous_id = id
      previous_new_record = new_record?
      yield
    rescue Exception
      @new_record = previous_new_record
      if id_present
        self.id = previous_id
      else
        @attributes.delete(self.class.primary_key)
        @attributes_cache.delete(self.class.primary_key)
      end
      raise
    end

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

Defined in ActiveRecord::Transactions

Type at least 2 characters to search.

↑↓ navigate · open · esc close