Exception: Mongoid::Errors::UnknownModel

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

Overview

This error is raised when trying to instantiate a model object from the value in the ‘_type’ field of a document and the class doesn’t exist.

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, value) ⇒ UnknownModel

Create the new error.

Examples:

Instantiate the error.

UnknownModel.new('InvalidClass', "invalid_class")

Parameters:

  • klass (String)

    The model class.

  • value (String)

    The value used to determine the (invalid) class.



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

def initialize(klass, value)
  super(
      compose_message("unknown_model", { klass: klass, value: value })
  )
end