Skip to Content
Learn
Associations II
Many to Many

So far we’ve made an app that stores data using two models. We used the has_many / belongs_to association to model a one-to-many relationship between the data.

But not all data is one-to-many. For example, a movie has many actors in the cast, but each actor also has many movies she’s starred in.

To model this data, we need a many-to-many relationship. Let’s see how to do this by building a Rails app for a movie website.

Instructions

1.

Create a new app named MovieApp.

2.

Install the gems.

3.

Run the local server and visit http://localhost:8000.

Folder Icon

Sign up to start coding

Already have an account?