instance method
rollback_active_record_state!
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v4.1.16Signature
rollback_active_record_state!()
Reset id and @new_record if the transaction rolls back.
Source
# File activerecord/lib/active_record/transactions.rb, line 154
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 154
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Transactions