Model Each Do Looping Problem

I have this strange loop going on. Here's my Data for instance in a Table called GROUPS account_id = 1 group_name = Acme account_id = 1 group_name = Disney account_id = 1 group_name = Pixar

/group/list.rhtml <%= render :partial => "grouplist", :collection => @groups %>

/group/_grouplist.rhtml <% @groups.each do |group| %>   <li><%= group.group_name %></li> <% end %>

../group_controller.rb def list   @groups = Group.find_all_by_account_id(session[:user_id]);   ...

Now, my view renders it like so:

- Acme - Disney - Pixar - Acme - Disney - Pixar - Acme - Disney - Pixar

I just want it to display only once - Acme - Disney - Pixar

I'm sure its so simple, but I am banging my head to find out!!!

/group/list.rhtml <%= render :partial => "grouplist", :collection => @groups %>

Using ":collection" makes this line automatically do the looping for you.

/group/_grouplist.rhtml <% @groups.each do |group| %>   <li><%= group.group_name %></li> <% end %>

So you don't need the loop in the partial. Take out the loop and I bet that'll fix your issue. I've made this mistake accidentally before too :slight_smile: