From the course: Ruby on Rails 6 Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Delete actions: Delete and destroy - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training
Delete actions: Delete and destroy
- [Instructor] We've now learned how to read, create, and update records. The remaining CRUD action is delete. Delete is also made up of two different actions. Delete and destroy. Delete would display a delete record form and Destroy would actually do the destruction of the record of the database. Notice that the RESTful route for destroy is going to use delete as its verb. There are a few other points we need to keep in mind. Delete and destroy are going to require an ID to be sent so that they can find an existing record and that just makes sense. You can't delete a record if it doesn't exist in the database. Delete is going to use find to find the record and destroy will use find and destroy. Now it can get confusing because the HTTP verb that we're using for destroy is called delete and there's also a rails method called delete that we can call on the object as well. But we want to make sure we're using destroy…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
Read action: Index4m 20s
-
Read action: Show4m
-
Adding basic forms to templates4m 51s
-
Create action: New4m 12s
-
Create action: Create5m 5s
-
Using strong parameters to regulate input4m 57s
-
Update actions: Edit and update6m 19s
-
Using partials and helpers to organize code6m 36s
-
Delete actions: Delete and destroy5m 50s
-
Challenge: Pages CRUD1m 23s
-
Solution: Pages CRUD4m 50s
-
-