class ActiveRecord::RecordNotDestroyed

Parent:
ActiveRecord::ActiveRecordError

Raised by ActiveRecord::Base#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

record[R]

Public Class Methods

new(message = nil, record = nil) Show source
# File activerecord/lib/active_record/errors.rb, line 185
def initialize(message = nil, record = nil)
  @record = record
  super(message)
end
Calls superclass method

© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.