Exception: Mongoid::Errors::UnknownAttribute

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

Overview

This error is raised when trying to set a value in Mongoid that is not already set with dynamic attributes or the field is not defined.

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(klass, name) ⇒ UnknownAttribute

Create the new error.

Examples:

Instantiate the error.

UnknownAttribute.new(Person, "gender")

Parameters:

  • klass (Class)

    The model class.

  • name (String | Symbol)

    The name of the attribute.



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

def initialize(klass, name)
  super(
    compose_message("unknown_attribute", { klass: klass.name, name: name })
  )
end