By using a rich join, we lose the ability to move directly from one side of the association to the other. Instead, we must go through the object in the middle. Rails provides a way to do it by defining a “has_many :through” association in addition to the rich join. This allows traversing the association in whichever way fits the circumstance best.
- [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 reach across the join easily…
- Creating and configuring a new Ruby on Rails project
- Generating controllers and views
- Handling server requests
- Using different types of routes
- Rendering and viewing templates
- Generating migrations and models
- Creating, updating, and deleting records
- Finding records with queries
- Understanding relationship types
- Writing controllers for CRUD
- Working with layouts and helpers
- Managing application assets
- Building forms
- Validating data
- Authenticating users
Skill Level Beginner
1. What Is Ruby on Rails?
2. Get Started
3. Controllers, Views, and Dynamic Content
4. Databases and Migrations
5. Models and ActiveRecord
7. CRUD, REST, and Resourceful Routes
8. Controllers and CRUD
9. Layouts, Partials, and View Helpers
12. Data Validation
13. Controller Features
14. User Authentication
15. Improve the Simple CMS
Next steps1m 44s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.