When using Mongoid referenced reletions what's the diffrence between dependent detroy and dependent delete since in the docs it tells:
:delete: Delete the child documents.
:destroy: Destroy the child documents.
In Mongoid (and also ActiveRecord I believe), delete
just removes the object from the database. destroy
will delete the object and run all of the appropriate callbacks that the model has defined. So if you have a before_destroy
callback on a model and you delete
an instance of that model, the before_destroy
callback will not be called.
So dependent: :destroy
runs the model's callbacks when deleting and dependent: :delete
does not.