Actors i step 7

Hi everybody,

I’m getting this error on actors I step 7 :

undefined method `image’ for nil:NilClass

I don’t know where it came from.

If somebody can help me !

This is my code:

<div class="main actor-show">
  <div class="container">
    <!-- Display an actor's info here -->
    <div class="actor">
      <!-- actor image -->
      <%= image_tag @actors.image %>
      <div class="info">
        <h3 class="actor-name"> <%= @actors.first_name %> <%= @actors.last_name %>  </h3>
        <p class="actor-bio"> <%= %> </p>

    <!-- Display each movie's info here -->
    <%= @movie.each do |a| %>
    <div class="movie">
      <!-- movie image -->
      <%= image_tag a.image %>
      <h3 class="movie-title"> <%= a.title %> </h3>
      <p class="movie-release-year"> <%= a.release_year %> </p>
      <p class="movie-plot"> <%= a.plot %> </p>
 <% end %>

Hi Tom,

  1. Inside <div class="actor">...</div>, you’re using the @actors variable, which doesn’t exist. Make it `@actor instead.
  2. In your loop through movies, you need to use the @movies (plural) variable instead of @movie (singular), and you should use m for the loop counter instead of a to avoid confusion.

I hope this helps, feel free to ask any more questions you may have :slight_smile:

1 Like

Thanks @zystvan It’s help a lot, i was blocked on it for a long time :slight_smile:

Have a good day !

1 Like

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