Exception: Mongoid::Errors::InvalidField

Inherits:
MongoidError
  • Object
show all
Defined in:
build/mongoid-7.3/lib/mongoid/errors/invalid_field.rb

Overview

This error is raised when trying to create a field that conflicts with an already defined method.

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) ⇒ InvalidField

Create the new error.

Examples:

Create the error.

InvalidField.new(person, :crazy_method_name)

Parameters:

  • klass (Class)

    The document class.

  • name (Symbol)

    The method name.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'build/mongoid-7.3/lib/mongoid/errors/invalid_field.rb', line 18

def initialize(klass, name)
  super(
    compose_message(
      "invalid_field",
      {
        name: name,
        origin: origin(klass, name),
        file: location(klass, name)[0],
        line: location(klass, name)[1]
      }
    )
  )
end