Associations II 4.3 Movies I

Hi! I’m not quite understanding what Movies I Part 3 wants.

This is the given instructions:

Then in the Movies controller, add the index action to display a list of all movies. To do this, fetch all movies from the database and store them in variable @movies.

This is what I have written

class MoviesController < ApplicationController
  def index
  @movies = Movies.all 

   def show
    @movies = Movies.find(params[:id])



I’m super confused. would appreciate some help! thank u

Hi @cherye,

You’re pretty close! Movie is the database table which stores all of the movies. Even though it sounds a little weird, being non-plural, you actually need to use Movie to get a movie out of the database, like this for example:

@movies = Movie.all

And in your show action, @movies should also be singular (@movie) since it’s only one movie :slight_smile:


ah, I see, thank you very much! :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.