Actors showing up more than once and some links show the movies while some don't


Continuing the discussion from Movies does not show up after clicking on an actor:

Yeah, actually my code is showing some actors twice and some actors only once and some thrice. When I click on the second occurance of an actor, it shows the movies while on first or third link, it doesn't shows the movie. Don't know why is it happening.
The code for index_html.erb is -

<% @actors.each do |a| %>

<%= image_tag a.image %>

<%= a.first_name %> <%= a.last_name %>

<%= link_to "Learn more", actor_path(a) %>

<%= %>

<% end %>

can somebody help ?


Hopefully you've already figured this out since it was posted such a long time ago but just in case:

In the actors controller, show is missing the listing of the movies, so it should be something like:

    def show
      @actor = Actor.find(params[:id]
      @movies = @actor.movies  # btw this line was super helpful to me!
        @movies.each do |m|
          puts m

Hopefully that helps!