group by - Rails group_by and in_groups_of error -


i have list of organisations, grouped , displayed name, in alphabetical order. want display these across 4 columns each letter, i.e.:

a a... a... a... a... a... a... a... a...  ...  z z... z...  

i have used following code:

<% @organisations.keys.sort.each |starting_letter| %>     <div class="page-chunk default">         <h6><%= starting_letter %></h6>         <% @organisations[starting_letter].each |organisations| %>             <% organisations.in_groups_of(4).each |column| %>                 <div class="one_quarter">                     <% column.each |organisation| %>                         <%= link_to organisation.name, organisation_path(organisation) %><br />                     <% end %>                 </div>             <% end %>         <% end %>     </div> <% end %> 

and in controller:

@organisations = organisation.all.group_by{ |org| org.name[0] } 

but undefined methodin_groups_of' #for troubles. if change code to@organisations[starting_letter].in_groups_of(4).each |organisations|then anilclass` error.

what have done wrong , how should fix it?

try organisations.in_groups_of(4, false) without false, fill in empty spots in last group nils, means try call name on nil.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -