I'm using Mongoid, and I have one class (Order) that "embeds_many" of another class (LineItem). Specifically, in Order, I have:
embeds_many :line_items, cascade_callbacks: true
And in LineItem, I have:
embedded_in :order
Everything works as it should except for the cascading_callbacks. When I make a change to an Order object and call "save", I would expect the "after_save" callbacks on all of the embedded LineItem objects to be called. This is not happening. I thought that was the point of cascading_callbacks.
Am I incorrect? Is something else required to make the save-related callbacks fire for each embedded document when the parent is saved and cascade_callbacks is set to true in the relationship?
I think, when you specify cascade callbacks: true in the parent document, the callbacks of the embedded documents are fired only when you make any change in the corresponding embedded document.
To check, change something in the embedded document and save the parent document. In this case I think the callbacks will be fired
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With