Changeset 8240
- Timestamp:
- 11/29/07 22:25:42 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/lib/active_record/transactions.rb
r8113 r8240 30 30 # Exceptions will force a ROLLBACK that returns the database to the state before the transaction was begun. Be aware, though, 31 31 # that the objects by default will _not_ have their instance data returned to their pre-transactional state. 32 #33 # == Rolling back a transaction manually34 #35 # Instead of relying on exceptions to rollback your transactions, you can also do so manually from within the scope36 # of the transaction by accepting a yield parameter and calling rollback! on it. Example:37 #38 # transaction do |transaction|39 # david.withdrawal(100)40 # mary.deposit(100)41 # transaction.rollback! # rolls back the transaction that was otherwise going to be successful42 # end43 32 # 44 33 # == Different ActiveRecord classes in a single transaction … … 81 70 # 82 71 # Also have in mind that exceptions thrown within a transaction block will be propagated (after triggering the ROLLBACK), so you 83 # should be ready to catch those in your application code. 72 # should be ready to catch those in your application code. One exception is the ActiveRecord::Rollback exception, which will 73 # trigger a ROLLBACK when raised, but not be re-raised by the transaction block. 84 74 module ClassMethods 85 75 def transaction(&block)