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.



Create a new app named MovieApp.


Install the gems.


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

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?