Embedded Associations
suggest changeMongoid allows Embedded Associations:
- One-to-one:
embeds_one/embedded_in - One-to-many:
embeds_many/embedded_in
To embed many addresses on a user, add this to User:
embeds_many :addresses
and this to Address:
embedded_in :user
Address documents are then stored inside the user document, and User gains an addresses method. There is no separate addresses collection.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents