Exception: Mongoid::Errors::MixedRelations

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

Attributes inherited from MongoidError

#problem, #resolution, #summary

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



24
25
26
27
28
29
30
31
# File 'build/mongoid-7.3/lib/mongoid/errors/mixed_relations.rb', line 24

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