What is the best way to do this? A Andover B Babson ... C ... . ... . ... . ... <%= @letter = ''a'' %> <% while @letter != ''z'' %> <%= @letter %> <% for school in @schools %> <% if school.title.first == @letter %> <%= link_to h (school.title), new_school_course_path(school) %> <% end %> <% end %> <br/> <%= @letter.succ %> <br/> <% end %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Dec 15, 6:18 pm, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What is the best way to do this? > > A Andover > B Babson ... > C ... > . ... > . ... > . ... > > <%= @letter = ''a'' %> > <% while @letter != ''z'' %> > <%= @letter %> > <% for school in @schools %> > <% if school.title.first == @letter %> > <%= link_to h (school.title), new_school_course_path(school) %> > <% end %> > <% end %> > <br/> > <%= @letter.succ %> > <br/> > <% end %>i think this: http://agilewebdevelopment.com/plugins/alphabar --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
<% (''A''..''Z'').each do |letter| this_letter = @schools.select {|school| school.title =~ /^#{letter}/} %> <%= letter %> <% this_letter.each do |schools| %> <%= link_to h (school.title), new_school_course_path(school) %> <% end %> <% end %> That''s just from memory, but it should work... --Jeremy On Dec 15, 2007 9:18 PM, edberner <eberner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > What is the best way to do this? > > A Andover > B Babson ... > C ... > . ... > . ... > . ... > > <%= @letter = ''a'' %> > <% while @letter != ''z'' %> > <%= @letter %> > <% for school in @schools %> > <% if school.title.first == @letter %> > <%= link_to h (school.title), new_school_course_path(school) %> > <% end %> > <% end %> > <br/> > <%= @letter.succ %> > <br/> > <% end %> > > > > >-- http://www.jeremymcanally.com/ My books: Ruby in Practice http://www.manning.com/mcanally/ My free Ruby e-book http://www.humblelittlerubybook.com/ My blogs: http://www.mrneighborly.com/ http://www.rubyinpractice.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 -~----------~----~----~----~------~----~------~--~---
On Dec 16, 2007, at 12:47 AM, Jeremy McAnally wrote:> On Dec 15, 2007 9:18 PM, edberner <eberner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> What is the best way to do this? >> >> A Andover >> B Babson ... >> C ... >> . ... >> . ... >> . ... >> >> <%= @letter = ''a'' %> >> <% while @letter != ''z'' %> >> <%= @letter %> >> <% for school in @schools %> >> <% if school.title.first == @letter %> >> <%= link_to h (school.title), >> new_school_course_path(school) %> >> <% end %> >> <% end %> >> <br/> >> <%= @letter.succ %> >> <br/> >> <% end %> >> > > <% > (''A''..''Z'').each do |letter| > this_letter = @schools.select {|school| school.title =~ /^#{letter}/} > %> > <%= letter %> > <% this_letter.each do |schools| %> > <%= link_to h (school.title), new_school_course_path(school) %> > <% end %> > <% end %> > > That''s just from memory, but it should work... > > --Jeremy > -- > http://www.jeremymcanally.com/ > > My books: > Ruby in Practice > http://www.manning.com/mcanally/ > > My free Ruby e-book > http://www.humblelittlerubybook.com/ > > My blogs: > http://www.mrneighborly.com/ > http://www.rubyinpractice.com/Or a little fancier: <% by_letter = @schools.group_by {|school| school.title[0,1]} -%> <dl> <% (''A''..''Z'').each do |letter| -%> <dt><%= letter %></dt> <% if by_letter.has_key?(letter) -%> <% by_letter[letter].sort.each do |school| -%> <dd><%= link_to h(school.title), new_school_course_path(school) %><br /></dd> <% end -%> <% else -%> <dd style="color: grey;">(none)</dd> <% end -%> <% end -%> </dl> -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---