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

Rich join associations - Ruby on Rails Tutorial

From the course: Ruby on Rails 6 Essential Training: Models and Associations

Start my 1-month free trial

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.…

Contents