class

ActiveRecord::RecordNotDestroyed

v8.0.0 - Show latest stable - Superclass: ActiveRecord::ActiveRecordError

Raised by {ActiveRecord::Base#destroy!}[rdoc-ref:Persistence#destroy!] when a record cannot be destroyed due to any of the before_destroy callbacks throwing :abort. See ActiveRecord::Callbacks for further details.

class User < ActiveRecord::Base
  before_destroy do
    throw :abort if still_active?
  end
end

User.first.destroy! # => raises an ActiveRecord::RecordNotDestroyed

Attributes

[R]record

Files

  • activerecord/lib/active_record/errors.rb