I have a big collection of items I want to display two columns of ordered lists. I''m pretty new to RoR, but I think there must be some way to do this with a helper. this is the code i want to split <ol> <% @items.each do |item| %> <li><a href="<%= item.id %>"><%= item.name %></a></li> <% end %> </ol> Thx! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2008-Jul-01 22:00 UTC
Re: How to split query results in two columns? Noob
> I have a big collection of items I want to display two columns of > ordered lists. I''m pretty new to RoR, but I think there must be some > way to do this with a helper. > > this is the code i want to split > > <ol> > <% @items.each do |item| %> > <li><a href="<%= item.id %>"><%= item.name %></a></li> > <% end %> > </ol>http://railscasts.com/episodes/28 Quoting... in_groups_of Have you ever wanted to visually line up items in rows and columns? The in_groups_of method makes this a cinch. <!-- tasks/index.rhtml --> <table> <% @tasks.in_groups_of(4, false) do |row_tasks| %> <tr> <% for task in row_tasks %> <td><%= task.name %></td> <% end %> </tr> <% end %> </table> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom wrote:>> </ol> > http://railscasts.com/episodes/28 > > Quoting... > > in_groups_of > Have you ever wanted to visually line up items in rows and columns? > The in_groups_of method makes this a cinch. >The only problem with in_groups_of is that the ordering goes horizontal. If you are looking for vertical ordering, read this thread http://www.ruby-forum.com/topic/137230 Peace, Phillip -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---