rollback_active_record_state!()
public
Reset id and @new_record if the transaction rolls
back.
# 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