Problem with 3/5 Movies III

I also have issues with this, and still no solution for it here on the forums, and the bug is still there.

Here’s my code:

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

and here’s my error:

NoMethodError in Movies#show
Showing /home/ccuser/workspace/learn-rails-many-to-many/app/views/movies/show.html.erb where line #20 raised:

undefined method `image' for nil:NilClass
Extracted source (around line #20):

17 <%= @actors.each do |actor| %>
18 <div class="actor">
19 <!-- actor image -->
20  <%= image_tag @actor.image %>
21 <h3 class="actor-name"> <%= @actor.first_name + " " + @actor.last_name  %> </h3>
22 <p class="actor-bio"> <%= %> </p>
23 </div>  

I have even clicked “give me the solution”, but all that did was marking everything green and compleated, and removed my code with nothing, so I still don’t know what’s right.

This is utterly bullcrap since we pay for this…
and this error poped up over a year ago according to the forum, and it’s still not fixed.

I found one error my self, and thats the = sign in <%= @actors.each do |actor| %>

which I now have removed, but that didn’t solve the problem so does anyone have any idea on why I get this error?
If you need any other part from the code just let me know and I’ll post it.

OK I have now tried this on part of the course on my own computer and something is wrong with the information, because I’ve done exactly what the instructions says and I still get this error.
So basicly there is something else I need to do to get this to work, but what?

And since the “Give med the solution” button only removes my code and don’t replace it and mark everything green I don’t get any useful changes.

So my question is which info i missing in the instructions?

Ok, I found the issue with my code and it was the @ before actor.image and so on.

But why is that? Since for the movies to show we needed the @ before movies.image. I’m guessing it’s due to the actor loop, and there for we don’t need the @ sign. would be nice if someone can explain the difference.

You are correct. You don’t need the @ symbol before actor because you are iterating over each actor in the actors array and displaying the information. When you do this via a loop, <% @actors.each do |actor| %>, you need to interact with the keyword between the pipes.

You need the @ symbol in front of movie because you are only getting the information on one movie which was initialized in the movies_controller and made available to the show.html.erb file as an instance variable when you navigated to the show page for that movie.