Associations II 4.3 Movies I


#1

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

This is the given instructions:

3.
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 
  end

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

  
 
end

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


#2

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:


#3

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


#4

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