You are missing the class names on associations:
module MyModule
class School
include Mongoid::Document
embeds_one :student, class_name: 'MyModule::Student'
end
end
module MyModule
class Student
include Mongoid::Document
embedded_in :school, class_name: 'MyModule::School'
end
end
An argument can be made that Mongoid should figure this out automatically, though a complication here is when the first of the models is loaded the other one isn't defined yet and hence the target class may be global or in the namespace and Mongoid has no way of knowing which is correct.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…