Exception: ActiveRecord::RecordNotSaved
- Inherits:
-
ActiveRecordError
- Object
- StandardError
- ActiveRecordError
- ActiveRecord::RecordNotSaved
- Defined in:
- lib/active_record/errors.rb
Overview
Raised by ActiveRecord::Base#save! and ActiveRecord::Base.update_attribute! methods when a record failed to validate or cannot be saved due to any of the before_*
callbacks throwing :abort
. See ActiveRecord::Callbacks for further details.
class Product < ActiveRecord::Base
before_save do
throw :abort if price < 0
end
end
Product.create! # => raises an ActiveRecord::RecordNotSaved
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(message = nil, record = nil) ⇒ RecordNotSaved
constructor
A new instance of RecordNotSaved.
Constructor Details
#initialize(message = nil, record = nil) ⇒ RecordNotSaved
Returns a new instance of RecordNotSaved.
151 152 153 154 |
# File 'lib/active_record/errors.rb', line 151 def initialize( = nil, record = nil) @record = record super() end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
149 150 151 |
# File 'lib/active_record/errors.rb', line 149 def record @record end |