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.
Generate a model named
Generate another model named
Generate a third model named
In app/models/movie.rb, inside the Movie class add the following methods:
has_many :parts has_many :actors, through: :parts
In app/models/actor.rb, add the following methods:
has_many :parts has_many :movies, through: :parts
In app/models/part.rb, add the following methods:
belongs_to :movie belongs_to :actor