See ActiveRecord::Transactions::ClassMethods for documentation.
Reset id and @new_record if the transaction rolls back.
# File 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
See ActiveRecord::Transactions::ClassMethods for detailed documentation.
# File lib/active_record/transactions.rb, line 187 def transaction(&block) self.class.transaction(&block) end
Executes method within a transaction and captures its return value as a status flag. If the status is true the transaction is committed, otherwise a ROLLBACK is issued. In any case the status flag is returned.
This method is available within the context of an ActiveRecord::Base instance.
# File lib/active_record/transactions.rb, line 226 def with_transaction_returning_status(method, *args) status = nil self.class.transaction do status = send(method, *args) raise ActiveRecord::Rollback unless status end status end
Generated with the Darkfish Rdoc Generator 2.