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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In Mongoid (and also ActiveRecord I believe),
deletejust removes the object from the database.destroywill delete the object and run all of the appropriate callbacks that the model has defined. So if you have abefore_destroycallback on a model and youdeletean instance of that model, thebefore_destroycallback will not be called.So
dependent: :destroyruns the model’s callbacks when deleting anddependent: :deletedoes not.