File: //usr/local/rvm/gems/ruby-2.6.8/doc/activerecord-6.1.4.1/ri/ActiveRecord/Rollback/cdesc-Rollback.ri
U:RDoc::NormalClass[iI"
Rollback:ETI"ActiveRecord::Rollback;TI"$ActiveRecord::ActiveRecordError;To:RDoc::Markup::Document:@parts[o;;[
o:RDoc::Markup::Paragraph;[I"W{ActiveRecord::Base.transaction}[rdoc-ref:Transactions::ClassMethods#transaction] ;TI"auses this exception to distinguish a deliberate rollback from other exceptional situations. ;TI"3Normally, raising an exception will cause the ;TI"X{.transaction}[rdoc-ref:Transactions::ClassMethods#transaction] method to rollback ;TI"Othe database transaction *and* pass on the exception. But if you raise an ;TI"ZActiveRecord::Rollback exception, then the database transaction will be rolled back, ;TI"&without passing on the exception.;To:RDoc::Markup::BlankLine o; ;[I"QFor example, you could do this in your controller to rollback a transaction:;T@o:RDoc::Markup::Verbatim;[I"4class BooksController < ActionController::Base
;TI" def create
;TI" Book.transaction do
;TI"* book = Book.new(params[:book])
;TI" book.save!
;TI" if today_is_friday?
;TI"M # The system must fail on Friday so that our support department
;TI"J # won't be out of job. We silently rollback this transaction
;TI") # without telling the user.
;TI"@ raise ActiveRecord::Rollback, "Call tech support!"
;TI" end
;TI"
end
;TI"P # ActiveRecord::Rollback is the only exception that won't be passed on
;TI"Q # by ActiveRecord::Base.transaction, so this line will still be reached
;TI" # even on Friday.
;TI" redirect_to root_url
;TI" end
;TI"end;T:@format0:
@fileI" lib/active_record/errors.rb;T:0@omit_headings_from_table_of_contents_below0;
0;0[ [ [ [[I"
class;T[[:public[ [:protected[ [:private[ [I"
instance;T[[;[ [;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;
0;0[@/I"ActiveRecord;TcRDoc::NormalModule