Related

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::Basedef createBook.transactiondobook=Book.new(params[:book])book.save!iftoday_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.raiseActiveRecord::Rollback,"Call tech support!"endend# 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_toroot_urlendend