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.
Many-to-many associations: Simple - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
Many-to-many associations: Simple
- [Teacher] Now that we've learned how to create one-to-many associations, we're ready to move on to learn many-to-many associations. We'll begin by looking at a simple join, and then move on to a more complex join in the next movie. Many-to-many associations are similar to one-to-many associations because they also have an object which has many objects which belong to it. The difference that as a many-to-many, the objects don't belong to it exclusively. For example, a project has_and_belongs_to_many :collaborators. The project can have many collaborators, but the collaborators can also have many projects. It's not like the project owns a collaborator exclusively. They're allowed to work on other projects, too. You have a BlogPost, which has_and_belongs_to_many :categories. If our BlogPost is both in the technology and training categories, it doesn't mean that no other BlogPost can be in the technology and training categories. Technology will have many BlogPosts. Training will have…
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)
-
-
-
-
-
-
-
-
-
-