Exception: Mongoid::Errors::ReadonlyAttribute

Inherits:
MongoidError
  • Object
show all
Defined in:
lib/mongoid/errors/readonly_attribute.rb

Overview

This error is raised when attempting the change the value of a readonly attribute after the document has been persisted.

Constant Summary

Constants inherited from MongoidError

MongoidError::BASE_KEY

Instance Method Summary collapse

Methods inherited from MongoidError

#compose_message

Constructor Details

#initialize(name, value) ⇒ ReadonlyAttribute

Create the new error.

Examples:

Create the new error.

ReadonlyAttribute.new(:title, "mr")

Parameters:

  • name (Symbol, String)

    The name of the attribute.

  • value (Object)

    The attempted set value.

Since:

  • 3.0.0


18
19
20
21
22
# File 'lib/mongoid/errors/readonly_attribute.rb', line 18

def initialize(name, value)
  super(
    compose_message("readonly_attribute", { name: name, value: value })
  )
end