I have a edge-casey case where I have an association that is analogous to the following:
Course has_many :students
Student belongs_to :course
Both Course and Student have some number of keys. Course has a name and a room number and a day of the week, for example.
We're exposing a web service for people to get students and classes. Clients will NEVER ask for student without asking for the course information to be included. But, we can't use EmbeddedDocument and embed ourse within Student because Courses themselves are also first class objects. We can, of course, use a standard association. However clients may requests thousands of students at one time and doing the join for each Student isn't smart.
WHAT WE WANT is to save Course objectes into their own Mongo collection AND when we set Student.course, it copies the course into Student.course (including mongo _id)
Clients will never be updating this data, so any overhead generated to write speed can be completely ignored.
I'm going to hack up a gem for this soon unless someone can point out tot be that this has already been done somewhere. Perhaps something like
Student belongs_to :course, :duplicates => true
Thanks!
Gary