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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.