1
如果有:embeds_many :foos
。依賴=>:需要embeds_many來銷燬?
是:dependent => :destroy
必填?或者,如果我銷燬父元素。各自的foos
將被自動刪除?
我試圖檢查控制檯Foo
,但得到:
Mongoid::Errors::InvalidCollection: Access to the collection for Foo is not allowed since it is an embedded document, please access a collection from the root document.
看看這個:http://mongoid.org/en/mongoid/v3/relations.html。他使用dependent:has_many:albums,dependent :: delete,belongs_to:label,dependent :: nullify。如果它自動銷燬嵌入式文檔,那麼爲什麼有一個相關的刪除和無效?沒有什麼可以抵消的。 – Donato 2015-03-07 04:53:54
由於has_many和belongs_to不是嵌入關係,它們是僅存儲屬於邊的關鍵的參照關係。 – rubish 2015-05-21 21:58:14