Reputation: 8631
I am calling a partial in one of my views like so:
<%= render :partial => 'events/attendees', :collection => @attendees %>
the partial however is running twice for some reason...here is the partial:
<% @attendees.each do |user| %>
<li><%= link_to user.name, user %></li>
<% end %>
and i verified that rails is in fact running this partial twice because the output shows each item from @attendees twice
Upvotes: 3
Views: 1023
Reputation: 65487
That's because one "loop" is from Rails (:collection
means that Rails will render the partial for each item in the collection, in this case @attendees
) and one loop via your own partial.
Change the partial to below (not sure about the relation between attendee/user, but here is a sample):
<li><%= link_to attendee.name, attendee.user %></li>
Or, change the call of the partial to:
<%= render :partial => 'events/attendees' %>
Upvotes: 8