Exception: ActiveModelPersistence::ObjectNotSavedError

Inherits:
ModelError
  • Object
show all
Defined in:
lib/active_model_persistence.rb

Overview

Raised when trying to save an invalid object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, object = nil) ⇒ ObjectNotSavedError

Create a new error

Examples:

ObjectNotSavedError.new('Invalid object', self)

Parameters:

  • message (String) (defaults to: nil)

    The error message

  • object (Object) (defaults to: nil)

    The object that was not saved



41
42
43
44
# File 'lib/active_model_persistence.rb', line 41

def initialize(message = nil, object = nil)
  @object = object
  super(message)
end

Instance Attribute Details

#objectObject (readonly)

The object that was not saved

Examples:

object = Object.new
error = ObjectNotSavedError.new('Invalid object', object)
error.object == object #=> true

Returns:

  • (Object)

    The object that was not saved



31
32
33
# File 'lib/active_model_persistence.rb', line 31

def object
  @object
end