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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -