Exception: ActiveObject::ObjectInvalid
- Inherits:
-
ActiveObjectError
- Object
- StandardError
- ActiveObjectError
- ActiveObject::ObjectInvalid
- Defined in:
- lib/active_object/validations.rb
Overview
Raised by save!
and create!
when the object is invalid. Use the object
method to retrieve the object which did not validate.
begin
complex_operation_that_calls_save!_internally
rescue ActiveObject::ObjectInvalid => invalid
puts invalid.record.errors
end
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
-
#initialize(object) ⇒ ObjectInvalid
constructor
A new instance of ObjectInvalid.
Constructor Details
#initialize(object) ⇒ ObjectInvalid
Returns a new instance of ObjectInvalid.
11 12 13 14 |
# File 'lib/active_object/validations.rb', line 11 def initialize(object) @object = object super("Validation failed: #{@object.errors..join(", ")}") end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
10 11 12 |
# File 'lib/active_object/validations.rb', line 10 def object @object end |