Exception: ActiveRecord::RecordNotDestroyed

Inherits:
ActiveRecordError show all
Defined in:
activerecord/lib/active_record/errors.rb

Overview

Raised by ActiveRecord::Base.destroy! when a call to destroy would return false.

begin
  complex_operation_that_internally_calls_destroy!
rescue ActiveRecord::RecordNotDestroyed => invalid
  puts invalid.record.errors
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, record = nil) ⇒ RecordNotDestroyed

Returns a new instance of RecordNotDestroyed.


74
75
76
77
# File 'activerecord/lib/active_record/errors.rb', line 74

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

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record


72
73
74
# File 'activerecord/lib/active_record/errors.rb', line 72

def record
  @record
end