Well done! The movies show up on the page.

Let’s add another action to display a specific movie and its actors. Looking at the seven standard controller actions, we need to use the show action to do this.



In the routes file, add another route to send requests to URLs like /movies/1 to the Movie controller’s show action. Use as: to name this route “movie”.


Then in the Movies controller, add the show action to display a specific movie and its actors.

  • First use Movie.find to find the movie by its id.
  • Then retrieve all actors that belong to the movie, and store them in @actors.

In app/view/movies/show.html.erb

  • Inside <div class="movie">...</div>, display the movie’s image, title, release year, and plot.
  • Below <h2>Cast</h2>, iterate through each actor and display the image, first name, last name, and bio.

Finally in app/views/movies/index.html.erb below a movie’s plot, use link_to to add a link to that movie:

  • Use “Learn more” for the link text
  • By giving the show route a name of “movie”, Rails automatically creates a helper method named movie_path, so use it to generate a URL to a specific movie’s path

Visit http://localhost:8000/movies in the browser. Click on a ‘Learn more’ to see a movie and its actors.

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?