123456789_123456789_123456789_123456789_123456789_

Exception: ActiveRecord::RecordNotDestroyed

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActiveRecordError, StandardError
Instance Chain:
self, ActiveRecordError, StandardError
Inherits: ActiveRecord::ActiveRecordError
Defined in: activerecord/lib/active_record/errors.rb

Overview

Raised by {ActiveRecord::Base#destroy!} when a record cannot be destroyed due to any of the before_destroy callbacks throwing :abort. See 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

Class Method Summary

Instance Attribute Summary

Constructor Details

.new(message = nil, record = nil) ⇒ RecordNotDestroyed

[ GitHub ]

  
# File 'activerecord/lib/active_record/errors.rb', line 185

def initialize(message = nil, record = nil)
  @record = record
  super(message)
end

Instance Attribute Details

#record (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/errors.rb', line 183

attr_reader :record