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 - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
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…
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
-
-
-
-
-
-
-
-
-
-
(Locked)
Read action: Index6m 31s
-
(Locked)
Read action: Show5m 22s
-
(Locked)
Form basics5m 13s
-
(Locked)
Create action: New4m 54s
-
(Locked)
Create action: Create5m 27s
-
(Locked)
Strong parameters6m 33s
-
(Locked)
Update actions: Edit/update7m 53s
-
(Locked)
Delete actions: Delete/destroy7m 11s
-
(Locked)
Flash hash7m 28s
-
Challenge: Pages and sections CRUD1m 43s
-
(Locked)
Solution: Pages and sections CRUD7m 38s
-
(Locked)
-
-
-
-
-
-
-
-