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!!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Aug 1, 2007, at 8:32 AM, bradigan wrote:> /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 :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---