Rails .each show once for duplicate results
Within a rails .each code, how can I eliminate duplicates from the result? PMRelationships is a relationship table that links people and movies MGRelationships is a relationship table that links genres and movies The process Im looking for is to find All a Person's genres through first PmRelationship then MgRelationship <% @pm_relationships = PmRelationship.where(:people_id => @person.id) %> <ul class="basic-info-genres"> <% @pm_relationships.each do |pm_relationship| %> <% @movie=Movie.find(pm_relationship.movie_id) %> <% @mg_relationships = MgRelationship.where(:movie_id => @movie.id) %> <%