diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-07-28 12:26:59 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-07-28 12:33:24 +0100 |
commit | 6e754551254a8cc64e034163f5d0dc155b450388 (patch) | |
tree | e697e85d8699654f04a790e5dc323c7007e87e31 /activerecord/lib/active_record/base.rb | |
parent | 10d9fe4bf3110c1d5de0c6b509fe0cbb9d5eda1d (diff) | |
download | rails-6e754551254a8cc64e034163f5d0dc155b450388.tar.gz rails-6e754551254a8cc64e034163f5d0dc155b450388.tar.bz2 rails-6e754551254a8cc64e034163f5d0dc155b450388.zip |
Merge docrails changes
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 4f5d72a0be..9cb64223e2 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -83,8 +83,33 @@ module ActiveRecord #:nodoc: class ReadOnlyRecord < ActiveRecordError end - # Used by Active Record transaction mechanism to distinguish rollback from other exceptional situations. - # You can use it to roll your transaction back explicitly in the block passed to +transaction+ method. + # ActiveRecord::Transactions::ClassMethods.transaction uses this exception + # to distinguish a deliberate rollback from other exceptional situations. + # Normally, raising an exception will cause the +transaction+ method to rollback + # the database transaction *and* pass on the exception. But if you raise an + # ActiveRecord::Rollback exception, then the database transaction will be rolled back, + # without passing on the exception. + # + # For example, you could do this in your controller to rollback a transaction: + # + # class BooksController < ActionController::Base + # def create + # Book.transaction do + # book = Book.new(params[:book]) + # book.save! + # if today_is_friday? + # # The system must fail on Friday so that our support department + # # won't be out of job. We silently rollback this transaction + # # without telling the user. + # raise ActiveRecord::Rollback, "Call tech support!" + # end + # end + # # ActiveRecord::Rollback is the only exception that won't be passed on + # # by ActiveRecord::Base.transaction, so this line will still be reached + # # even on Friday. + # redirect_to root_url + # end + # end class Rollback < ActiveRecordError end |