From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

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

Traverse a rich association

Traverse a rich association - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Traverse a rich association

- [Narrator] In the last movie, we created a rich join between admin users and sections by using section edits. While we gain the ability to add complexity of other attributes and methods inside our section edit's model, we lost something at the same time. We now have to go through an extra step to get from one side of the association over to the other. For example, in our simple, has and belongs to many join, if we wanted to know all of the admin users who could edit a page, we could just request the array of admin users, page dot admin users and we'd get back an array. It would reach across the join table to the other side of the association but in our rich join, we can't just ask for section's admin users because there is no direct relationship between section and admin user. There's a model that's in between now. We can still do it, we just have to go through that extra step of going through the section edits and looking up each one's admin user. What we really want, is a way to…

Contents