Learn to implement a basic “delete” and “destroy” actions by writing controller code and the related HTML for the view template. The delete action is a Read operation which displays an HTML form for preparing to update a database record. The delete action is optional and commonly omitted from Rails applications. The destroy action is a Delete operation that removes a single record from the database.
- [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 sure that we don't accidentally delete something…
- Creating and configuring a new Ruby on Rails project
- Generating controllers and views
- Handling server requests
- Using different types of routes
- Rendering and viewing templates
- Generating migrations and models
- Creating, updating, and deleting records
- Finding records with queries
- Understanding relationship types
- Writing controllers for CRUD
- Working with layouts and helpers
- Managing application assets
- Building forms
- Validating data
- Authenticating users
Skill Level Beginner
1. What Is Ruby on Rails?
2. Get Started
3. Controllers, Views, and Dynamic Content
4. Databases and Migrations
5. Models and ActiveRecord
7. CRUD, REST, and Resourceful Routes
8. Controllers and CRUD
9. Layouts, Partials, and View Helpers
12. Data Validation
13. Controller Features
14. User Authentication
15. Improve the Simple CMS
Next steps1m 44s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.