From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Delete actions: Delete/destroy

Delete actions: Delete/destroy - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Delete actions: Delete/destroy

- [Instructor] We've now seen how to create, read, and update records from the controller. The last part of CRUD is delete and that's what we'll learn to do in this movie. You'll remember, the delete can be defined by two standard rails actions. Delete and destroy. Like the other form actions that we've seen, delete displays a form and destroy processes that form. There are a few other key points to be aware of. First, delete also wants an id, just like we did with update. And it makes sense that we can't destroy a record of the database if we don't have an id so we can find it. We need to have an id to reference the record that we want. When it processes the form, destroy finds the subject and then calls the destroy method on it. Remember that there's also a method called delete. But we want to make sure that we're using destroy. You may be wondering, what does a delete form look like? I mean, we're not editing any values. The delete page mostly serves as a confirmation page to make…

Contents