From the course: Ruby on Rails 6 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 records using ActiveRecord - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training
Update records using ActiveRecord
- [Instructor] In the last movie, we used our models to create records in the database. In this movie, we will learn to update those records. Like creating records, there're two techniques we can use for updating. The first I call the find and save technique. First, you find a record, then you set its values and then you save it. It's very similar to what we were doing when we were working with new before. We're finding the records so that we have an instance to work with, we set the values and then we save it. The second technique is what we would call find and update. We still have to find the record but then we set the values and save all in one step so it's a two-step process. Let's try them both. If you're still in the console after the last movie, that's fine, there's no need to exit and go back in. But I will launch my Rails console again. The first step is to find the record that we want. So we'll have subject…
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)
Understanding ActiveRecord and ActiveRelation4m 32s
-
(Locked)
Using the Rails console to interact with a Rails project3m 36s
-
Create records using ActiveRecord5m 11s
-
(Locked)
Update records using ActiveRecord3m 53s
-
(Locked)
Delete records using ActiveRecord3m 18s
-
(Locked)
Find records using ActiveRecord6m 33s
-
(Locked)
Define one-to-many associations between models6m 30s
-
(Locked)
-
-
-