What is the difference between destroy and delete




















What is the difference between model. Please log in or register to add a comment. Please log in or register to answer this question. Related questions. In the following example, when a patient is destroyed, I have three classes: School, Account, and Administratorship.

I would like to destroy a nested model if its attributes are blanked out in the form for the parent model - however, it appears that the ActiveRecord I missing something? Is there a way around this? If your multiple parent objects share common children objects, then calling destroy on specific parent object will delete children objects which are shared among other multiple parents. Python Javascript Linux Cheat sheet Contact. Difference between Destroy and Delete Basically destroy runs any callbacks on the model while delete doesn't.

Their use really matters: If your multiple parent objects share common children objects, then calling destroy on specific parent object will delete children objects which are shared among other multiple parents. The former will be executed based on the :dependent option passed into the association. Basically "delete" sends a query directly to the database to delete the record. The "destroy" method takes the passed id, fetches the model from the database using the "find" method, then calls destroy on that.

This means the callbacks are triggered. You would want to use "delete" if you don't want the callbacks to be triggered or you want better performance. Otherwise and most of the time you will want to use "destroy". Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?

Collectives on Stack Overflow. Learn more. Difference between Destroy and Delete Ask Question. Asked 7 years, 7 months ago. Active 3 years ago. Viewed k times. What is the difference between model.

Improve this question. Saggex Saggex 3, 2 2 gold badges 20 20 silver badges 33 33 bronze badges. Add a comment. Active Oldest Votes.



0コメント

  • 1000 / 1000