5.4 Movies || using link_to in order to add path to specific movie

I’m trying to go through step 5.4 where we are about to just add line to link specific movie from index view with designed view created on show.erb.html template.

I am constantly getting this error: Did you add link for movie?
when my code in index.erb.html file looks like:

    <% @movies.each do |m| %>

<%= m.title %>

<%= m.release_year %>

<%= m.plot %>

<%= link_to 'Learn more', movie_path(m) %>
<% end %>

Movies controller has following code:

class MoviesController < ApplicationController
	def index
		@movies = Movie.all
  def show
    	@movie = Movie.find(params[:id])
    	@actors = @movie.actors.all
  def movie_params

and routes.rb also looks fine for me:

Rails.application.routes.draw do

	get '/movies' => 'movies#index'
  get '/movies/:id' => 'movies#show', as: :movie

Does anyone see what I did wrong or why am I getting this kind of error message?

Hi @witekm,

Try using double quotes (") around Learn more, like this:

<%= link_to "Learn more", movie_path(m) %>

It shouldn’t cause a difference, but sometimes Codecademy’s code checker will be too thorough in making sure your code exactly matches what they want.

1 Like

@zystvan many thanks, that change made a difference and code is working fine right now.

1 Like

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