From the course: Ruby on Rails 6 Essential Training: Models and Associations
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Rich join associations - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training: Models and Associations
Rich join associations
- [Instructor] Now that we understand about has and belongs to many relationships, I want us to learn about something I call rich joins. We already have talked about has and belongs to many. And we understand the purpose of having that join table between the other tables. So for example, if we have courses and students, that join table might be courses_students, that holds the ratio between them, and we saw that it doesn't have a model it's just a join table that works behind the scenes. But here's where it falls short. Imagine, if we want to keep track of more information than just the fact that a student is linked to a class. We might want to keep track of their seat number, or the date they signed up, the date they last attended, or how many times they've been absent. That information belongs in this join table because that join table is essentially the record that maintains the presence of the student in the class.…
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)
Work with associations7m 35s
-
(Locked)
Validate presence with belongs_to2m 39s
-
(Locked)
Destroy dependent-related records3m 10s
-
(Locked)
Has and belongs to many relationships10m 3s
-
(Locked)
Rich join associations6m 28s
-
(Locked)
Traversing a rich join association3m 38s
-
(Locked)
Joining tables during queries6m 51s
-
(Locked)
-