Exception: Mongoid::Errors::UnknownModel

Inherits:
MongoidError
  • Object
show all
Defined in:
build/mongoid-7.3/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.

Since:

  • 7.0.0



20
21
22
23
24
# File 'build/mongoid-7.3/lib/mongoid/errors/unknown_model.rb', line 20

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