Mongoid: Calling delete vs. destroy on a record with associations

using Mongoid and i got a model that has a bunch of associations defined with dependent: :destroy. and a specific primary_key defined (that is not the _id).

Now my understanding was that when i call .destroy all of the associations will be destroyed as well (possibly chaining further down). Opposed to calling .delete where i would expect the associations to be untouched.

Is that assumption correct?
Because i tried to re-create some records. Made a new one, set attributes from the old one (especially my primary_key field used to link the associations), then delete the old one.
Intention was that the new records keeps every associated record of the former.
But something happened here and i can’t even begin to understand what. Lots of the associated data was cascading .destroy while i only called delete on the old record?!?

Per https://jira.mongodb.org/browse/MONGOID-5060 this is an open issue in Mongoid.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.