I have an array "$a" and the below code in my view displays all the elements in a single column. How do I display them into 5 columns? I am not sure if it should be done thru ruby code, or html tags or CSS. Please suggest. thanks <ul> <% for w in $a %> <%= w %> <% end %> </ul> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2010-Nov-05 03:21 UTC
Re: Display an array into multiple columns in a view
Have a look at the Enumerable class: http://ruby-doc.org/core/classes/Enumerable.html each_slice in particular looks likely what you need. Walter On Nov 4, 2010, at 10:59 PM, Dv Dasari wrote:> I have an array "$a" and the below code in my view displays all the > elements in a single column. How do I display them into 5 columns? > > I am not sure if it should be done thru ruby code, or html tags or > CSS. > Please suggest. thanks > > <ul> > <% for w in $a %> > <%= w %> > <% end %> > </ul> > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 > . >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Nov 5, 2010 at 10:59 AM, Dv Dasari <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have an array "$a" and the below code in my view displays all the > elements in a single column. How do I display them into 5 columns? > > I am not sure if it should be done thru ruby code, or html tags or CSS. > Please suggest. thanks > > <ul> > <% for w in $a %> > <%= w %> > <% end %> > </ul> >This is more of a CSS issue. Style your <li>''s as floated. Or you can just drop them in a <table>. -- Erol M. Fornoles http://github.com/Erol http://twitter.com/erolfornoles http://ph.linkedin.com/in/erolfornoles -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You may want to look into using a partial with a collection -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Davis wrote in post #959491:> Have a look at the Enumerable class: > http://ruby-doc.org/core/classes/Enumerable.html > each_slice in particular looks likely what you need. > > WalterThanks that worked -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.