Exception: ActiveObject::ObjectInvalid

Inherits:
ActiveObjectError show all
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

Instance Method Summary collapse

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.full_messages.join(", ")}")
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



10
11
12
# File 'lib/active_object/validations.rb', line 10

def object
  @object
end