Would it be possible to omit requirement for embedded_in statement

27 views
Skip to first unread message

TheR

unread,
Aug 28, 2014, 7:50:40 AM8/28/14
to mon...@googlegroups.com

I didn't look into source of mongoid, but is there a good reason that embedded_in statement must be also present in embedded object although fact that object is embedded is already defined by embeds_many or embeds_one in model definition of document that has documents embedded.

I will try to explain on a case. I have a document (model) ''Attachment'' which can be embedded in lots of models of my application. I even think that this attachment model is so good that it can be published as standalone gem so it can can be embedded in any application that uses that gem.

But here is my problem. I have to write into attachment model embedded_in statement every time, document gets embedded into another document. Which is of course a ''no go'' if code is loaded as gem.

I can think of one ''good'' reason for this. It mimics the ActiveRecord has_many and belongs_to behaviour which is a lot more understandable since AR this way connects 3 tables together. In mongoid everything is saved to same table (document) so embedded_in should not be needed at all.

Or have I missed something.

by
TheR



Reply all
Reply to author
Forward
0 new messages