From the course: Ruby on Rails 5 Essential Training
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Update records - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
Update records
- [Instructor] In the last movie, we learned to create records using Active Record. In this movie, we're going to learn to update those records. Like creating records, there are two techniques that we can use for updating. One, is where you set the attributes one at a time, and then save. And one, where you set the attributes and save it all at once. Let's first look at the technique I'll call find save. First, you find a record, then you set its values, and then you save it. It's very similar to what we had with new save. The other technique, is using find and update attributes. We still have to find the record, but then, we can 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'm gonna launch my console again, and the first step is going to be to find the record that we want. I'm going to use subject equals subject dot find one. This…
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)
ActiveRecord and ActiveRelation4m 32s
-
(Locked)
Model naming5m 52s
-
(Locked)
Model attributes2m 51s
-
(Locked)
The Rails console3m 17s
-
(Locked)
Create records4m 53s
-
(Locked)
Update records3m 16s
-
(Locked)
Delete records2m 29s
-
(Locked)
Find records5m 48s
-
(Locked)
Query methods: Conditions7m 39s
-
(Locked)
Query methods: Order, limit, and offset6m 29s
-
(Locked)
Named scopes8m 26s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-