Exception: ActiveRecord::RecordNotDestroyed
- Inherits:
-
ActiveRecordError
- Object
- StandardError
- ActiveRecordError
- ActiveRecord::RecordNotDestroyed
- Defined in:
- 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 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
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(message = nil, record = nil) ⇒ RecordNotDestroyed
constructor
A new instance of RecordNotDestroyed.
Constructor Details
#initialize(message = nil, record = nil) ⇒ RecordNotDestroyed
Returns a new instance of RecordNotDestroyed.
172 173 174 175 |
# File 'lib/active_record/errors.rb', line 172 def initialize( = nil, record = nil) @record = record super() end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
170 171 172 |
# File 'lib/active_record/errors.rb', line 170 def record @record end |