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

Methods

Attributes

[R] record

Class Public methods

new(message = nil, record = nil)

📝 Source code
# File activerecord/lib/active_record/errors.rb, line 164
    def initialize(message = nil, record = nil)
      @record = record
      super(message)
    end
🔎 See on GitHub