Exception: Mongoid::Errors::InvalidField

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

Overview

This error is raised when trying to create a field that conflicts with a Mongoid internal attribute or method.

Example:

InvalidField.new('collection')

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ InvalidField

Returns a new instance of InvalidField.



97
98
99
# File 'lib/mongoid/errors.rb', line 97

def initialize(name)
  @name = name
end

Instance Method Details

#messageObject



100
101
102
103
104
105
# File 'lib/mongoid/errors.rb', line 100

def message
  "Defining a field named '#{@name}' is not allowed. " +
    "Do not define fields that conflict with Mongoid internal attributes " +
    "or method names. Use Document#instance_methods to see what " +
    "names this includes."
end