Exception: Mongoid::Errors::MixedRelations

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

Overview

This error is raised when trying to reference an embedded document from a document in another collection that is not its parent.

Examples:

An illegal reference to an embedded document.

class Post
  include Mongoid::Document
  references_many :addresses
end

class Address
  include Mongoid::Document
  embedded_in :person
  referenced_in :post
end

Since:

  • 2.0.0

Constant Summary

Constants inherited from MongoidError

Mongoid::Errors::MongoidError::BASE_KEY

Instance Method Summary collapse

Methods inherited from MongoidError

#compose_message

Constructor Details

#initialize(root_klass, embedded_klass) ⇒ MixedRelations

Returns a new instance of MixedRelations.

Since:

  • 2.0.0



22
23
24
25
26
27
28
29
# File 'lib/mongoid/errors/mixed_relations.rb', line 22

def initialize(root_klass, embedded_klass)
  super(
    compose_message(
      "mixed_relations",
      { root: root_klass, embedded: embedded_klass }
    )
  )
end