Exception: Mongoid::Errors::InvalidFieldOption

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

Overview

This error is raised when trying to create a field that has an invalid option.

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, option, valid) ⇒ InvalidFieldOption

Create the new error.

Examples:

Create the error.

InvalidFieldOption.new(Model, :name, :localized, [ :localize ])

Parameters:

  • klass (Class)

    The document class.

  • name (Symbol)

    The method name.

  • option (Symbol)

    The option name.

  • valid (Array<Symbol>)

    All the valid options.



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mongoid/errors/invalid_field_option.rb', line 20

def initialize(klass, name, option, valid)
  super(
    compose_message(
      "invalid_field_option",
      {
        name: name,
        klass: klass,
        option: option,
        valid: valid.join(", ")
      }
    )
  )
end