我想写FactoryGirl类来创建公司。模型如下:
Mongoid::Errors::InvalidPath:
message:
Having a root path assigned for Company::Contact 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, Company::Contact is also referenced via a has_many from a root document in another collection. Double check the relation definitions and fix any instances where embedded documents are improperly referenced from other collections
收到的错误是
失败/错误:create_list(:company_contact,1,company:company)
pom.xml, package.json, Dockerfiles, helm charts
我应该如何处理?我无法改变模型。
答案 0 :(得分:0)
您的关联类名称错误:
module Company
class Contact
include Mongoid::Document
include ActiveModel::Validations
embedded_in :company, class_name: 'Company::Company'
end
end