embedded_in – resolving children
The embedded_in
method tells us in which object this is embedded. It's very important that this should be configured when we are setting up the embedded relations.
Tip
Without the embedded_in
method in the model, the document would not get embedded at all. This is because the method is used to find the inverse relation!
class Review include Mongoid::Document embedded_in :book end
This tells Mongoid that the review document is embedded inside the book.