Error: Did you display the movie's title? Even though I did

I’m in the lesson Associations II, exercise 5 (Movies II). In the instructions, I am on Step 3. This step says to do the following:

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

Here is what I have (below). Why is it telling me I didn’t display the movie’s title?

  <div class="info">
    <% @movie.image %>
    <h3 class="movie-title">
      <% @movie.title %>
    </h3>
    <p class="movie-release-year">
      <% @movie.release_year %>
    </p>
    <p class="movie-plot">
      <% @movie.plot %>
    </p>
  </div>
</div>

<h2>Cast</h2>
<% @actors.each do |a| %>
<div class="actor">
  <% a.image %>
  <h3 class="actor-name">
    <% a.first_name %> <% a.last_name %>
  </h3>
  <p class="actor-bio">
    <% a.bio %>
  </p>
</div>
<% end %>

I have <% @movie.title %> in the right place but when I try to “Run” it, it says “Did you display the movie’s title?”. What am I doing wrong?

May be you can change

<% @movie.image %>
to
<img scr=" <%= @movie.image %> " >

:wink:

2 Likes

Instead of:

<%= @movie.image %>

You should user Ruby’s built in image_tag like so:

<%= image_tag @movie.image %>

Thanks for the replies. I was racing through it and all my tags started with “<%” instead of “<%=”. That was the issue…

1 Like