From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Many-to-many associations: Rich

Many-to-many associations: Rich - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Many-to-many associations: Rich

- [Voiceover] We've seen how to create simple many-to-many associations using has_and_belongs_to_many. In this movie, we're gonna add more complexity to our join tables. I call these rich joins. First, to understand why we need this complexity, let's go back to the many-to-many diagram for the beginning of this chapter. This is a classic many-to-many example. We have a number of courses, we have a number of students taking these courses. There will be a table named courses and a table named students, and in the simple join, we would have a join table between them, which we would call courses_students. In the join table will be two foreign keys, one for the course, and one for the student. Here's where the simple join falls short, though. Imagine that we wanna keep track of more information than just the fact that a student is participating in a class. You might wanna keep track of their seat number, or the date they signed up, or the date they last attended, or how many times they've…

Contents