Actors 1 part 7 undefined method `image' for nil:NilClass


#1

getting error in title and cannot figure out why undefined method `image' for nil:NilClass


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

<h2>Movies</h2>
<% @movies.each do |movie|%>
<!-- Display each movie's info here -->
<div class="movie">
  <%=image_tag movie.image%>
  <!-- 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>
<%end%>



#2

Hi James,

You can't have a plural (@actors) acting like a singular (@actor or actor in a each do |actor| loop). So, you should wrap the first section of your code in a each do |actor| loop, like this:

<% @actors.each do |actor| %>
  <!-- the original code in the first section, -->
  <!-- but with `@actors` replaced with `actor` -->
<% end %>