class ActiveRecord::Rollback
end
end
redirect_to root_url
# even on Friday.
# by ActiveRecord::Base.transaction, so this line will still be reached
# ActiveRecord::Rollback is the only exception that won’t be passed on
end
end
raise ActiveRecord::Rollback
# without telling the user.
# won’t be out of job. We silently rollback this transaction
# The system must fail on Friday so that our support department
if today_is_friday?
book.save!
book = Book.new(params)
Book.transaction do
def create
class BooksController < ActionController::Base
For example, you could do this in your controller to rollback a transaction:
without passing on the exception.
ActiveRecord::Rollback exception, then the database transaction will be rolled back,
the database transaction and pass on the exception. But if you raise an
method to rollback
Normally, raising an exception will cause the
uses this exception to distinguish a deliberate rollback from other exceptional situations.