diff options
Diffstat (limited to 'activerecord/lib/active_record/transactions.rb')
-rw-r--r-- | activerecord/lib/active_record/transactions.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 77a8a14a2a..d9bfd331c6 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -32,6 +32,17 @@ module ActiveRecord # Exceptions will force a ROLLBACK that returns the database to the state before the transaction was begun. Be aware, though, # that the objects by default will _not_ have their instance data returned to their pre-transactional state. # + # == Rolling back a transaction manually + # + # Instead of relying on exceptions to rollback your transactions, you can also do so manually from within the scope + # of the transaction by accepting a yield parameter and calling rollback! on it. Example: + # + # transaction do |transaction| + # david.withdrawal(100) + # mary.deposit(100) + # transaction.rollback! # rolls back the transaction that was otherwise going to be successful + # end + # # == Transactions are not distributed across database connections # # A transaction acts on a single database connection. If you have |