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.
Update actions: Edit/update - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
Update actions: Edit/update
- [Instructor] We've added code which will create records from our controller. Now, we want to be able to update existing records from the controller. Like create, there are two standard Rails actions for updating. Edit displays the form, while update processes the form. In fact, this two-step process of updating records is almost exactly like the process we just saw for creating them. There are only two key differences. The first is that we need to make sure that we have an ID. New and create didn't need an ID, because there was no record in the database yet, but edit and update require there be an ID so we can find that existing record. Once edit retrieves that existing record, it will use its values to pre-populate the form. Update will also need to find the object before it can update it. The second difference is going to be in the form processing. Create instantiated a new object, and then saved it. Update is going to find an existing object, and then use update attributes in…
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)
-
-
-
-
-
-
-
-