Details
-
Improvement
-
Status: Backlog
-
Minor - P4
-
Resolution: Unresolved
-
None
-
None
-
None
Description
require 'bundler/inline' |
|
gemfile do |
source 'https://rubygems.org' |
|
gem 'mongoid' |
end
|
|
Tempfile.open(%w(config .yml)) do |f| |
uri = 'mongodb://mongo/test' |
|
f.write(<<~YAML) |
development:
|
clients:
|
default:
|
uri: #{uri} |
YAML |
f.flush
|
|
Mongoid.load!(f.path, 'development') |
Mongoid::Clients.clients.each do |_, client| |
client.logger.level = Logger::ERROR |
end |
end
|
|
class Parent |
include Mongoid::Document
|
|
embeds_one :embedded_child |
end
|
|
class EmbeddedChild |
include Mongoid::Document
|
|
embedded_in :parent, polymorphic: true |
end
|
|
EmbeddedChild.create!(parent: Parent.create!)
|
|
__END__
|
Mongoid::Errors::InvalidPath:
|
message:
|
Having a root path assigned for EmbeddedChild is invalid. |
summary:
|
Mongoid has two different path objects for determining the location of a document in the database, Root and Embedded. This error is raised when an embedded document somehow gets a root path assigned. |
resolution:
|
Most likely your embedded model, EmbeddedChild is also referenced via a has_many from a root document in another collection. Double check the association definitions and fix any instances where embedded documents are improperly referenced from other collections. |
from /usr/local/bundle/gems/mongoid-7.1.2/lib/mongoid/atomic/paths/root.rb:36:in `insert_modifier' |
Is this intentional?