Ruby on Rails Splitting or Slicing list into columns -


@locations = location.all #current listing  @locations = location.slice(5) or location.split(5) 

with ruby i'm trying split list 4 columns, limiting each column 5 each; neither slicing or splitting seems work. idea of might doing wrong? appreciated.

you want use in_groups_of:

http://railscasts.com/episodes/28-in-groups-of

here's ryan bates' example usage railscast:

<table> <% @tasks.in_groups_of(4, false) |row_tasks| %>   <tr>     <% task in row_tasks %>       <td><%= task.name %></td>     <% end %>   </tr> <% end %> </table> 

Comments

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -