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 - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
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…
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)
Relationship types7m 2s
-
(Locked)
One-to-one associations9m 42s
-
(Locked)
One-to-many associations7m 54s
-
(Locked)
belongs_to presence validation4m 18s
-
(Locked)
Many-to-many associations: Simple9m 58s
-
(Locked)
Many-to-many associations: Rich10m 17s
-
(Locked)
Traverse a rich association5m 24s
-
(Locked)
-
-
-
-
-
-
-
-
-
-