Learn
Looking at the request/response cycle, we need four parts to the build the movie app: models, controllers, routes, and views.
Let’s begin by creating the models.
Instructions
1.
Generate a model named Movie
.
2.
Generate another model named Actor
.
3.
Generate a third model named Part
.
4.
In app/models/movie.rb, inside the Movie class add the following methods:
has_many :parts has_many :actors, through: :parts
5.
In app/models/actor.rb, add the following methods:
has_many :parts has_many :movies, through: :parts
6.
In app/models/part.rb, add the following methods:
belongs_to :movie belongs_to :actor
Sign up to start coding
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.