Exception: Mongoid::Errors::ReadonlyAttribute

Inherits:
MongoidError
  • Object
show all
Defined in:
build/mongoid-7.3/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 Attribute Summary

Attributes inherited from MongoidError

#problem, #resolution, #summary

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



20
21
22
23
24
# File 'build/mongoid-7.3/lib/mongoid/errors/readonly_attribute.rb', line 20

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