Hello, I was thinking about doing an alphabetical navigation for i.e list of users (there would be alphabet at the top of the list and by clicking on a character the list would get filtered). I did some googling but didn''t find any plugin or quick hack sorting this problem out. It''s however such a common thing that I was wondering whether there isn''t really some. Any suggestions or ideas are very welcome Thanks Jakub -- There is only one success - to be able to spend your life in your own way.
Wow.. I was just finishing up something on just that topic. Let me know if this helps you and give me some feedback if you can! http://www.napcsweb.com/howto/rails/aznavigation.pdf On 11/30/06, Jakub Kahovec <jakub.kahovec-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > Hello, > I was thinking about doing an alphabetical navigation for i.e list of > users (there would be alphabet at the top of the list and by clicking on > a character the list would get filtered). > I did some googling but didn''t find any plugin or quick hack sorting > this problem out. It''s however such a common thing that I was wondering > whether there isn''t really some. > Any suggestions or ideas are very welcome > Thanks > Jakub > > -- > There is only one success - to be able to spend your life in your own way. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
maybe something like view: <% (''A''...''Z'').each do |letter| -%> <%= link_to letter, :controller => :user, :action => :list, :starts_with => letter -%> <% end -%> <% @users.each do |user| -%> ... <% end -%> model: class User < ActiveRecord::Base def find_by_last_initial(initial) # note: use of mysql db functions may not be portable find(:all, :conditions => ["UCASE(LEFT(last_name,1)) = ?", initial.upcase] end end controller: class UserController < ApplicationController def list if params[:starts_with] @users = User.find_by_last_initial(params[:starts_with]) else @users = user.find(:all) end end end On 11/30/06, Jakub Kahovec <jakub.kahovec-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hello, > I was thinking about doing an alphabetical navigation for i.e list of > users (there would be alphabet at the top of the list and by clicking on > a character the list would get filtered). > I did some googling but didn''t find any plugin or quick hack sorting > this problem out. It''s however such a common thing that I was wondering > whether there isn''t really some. > Any suggestions or ideas are very welcome > Thanks > Jakub > > -- > There is only one success - to be able to spend your life in your own way. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thank you very much Chris, that''s exactly what I was dreaming about ;-) Jakub Chris Hall wrote:> maybe something like > > view: > > <% (''A''...''Z'').each do |letter| -%> > <%= link_to letter, :controller => :user, :action => :list, > :starts_with => letter -%> > <% end -%> > <% @users.each do |user| -%> > ... > <% end -%> > > > model: > > class User < ActiveRecord::Base > def find_by_last_initial(initial) > # note: use of mysql db functions may not be portable > find(:all, :conditions => ["UCASE(LEFT(last_name,1)) = ?", initial.upcase] > end > end > > controller: > > class UserController < ApplicationController > def list > if params[:starts_with] > @users = User.find_by_last_initial(params[:starts_with]) > else > @users = user.find(:all) > end > end > end > > On 11/30/06, Jakub Kahovec <jakub.kahovec-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> Hello, >> I was thinking about doing an alphabetical navigation for i.e list of >> users (there would be alphabet at the top of the list and by clicking on >> a character the list would get filtered). >> I did some googling but didn''t find any plugin or quick hack sorting >> this problem out. It''s however such a common thing that I was wondering >> whether there isn''t really some. >> Any suggestions or ideas are very welcome >> Thanks >> Jakub >> >> -- >> There is only one success - to be able to spend your life in your own way. >> >> >> >> >> > > --~--~---------~--~----~------------~-------~--~----~ > 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 > -~----------~----~----~----~------~----~------~--~--- > > >-- There is only one success - to be able to spend your life in your own way.
Hello Brian, I''m sorry I overlooked your post and implemented it by Chris''s suggestion. I will try, however, to look at your writing and give you some feedback. Cheers Jakub Brian Hogan wrote:> Wow.. > > I was just finishing up something on just that topic. Let me know if > this helps you and give me some feedback if you can! > > http://www.napcsweb.com/howto/rails/aznavigation.pdf > > > > On 11/30/06, *Jakub Kahovec* <jakub.kahovec-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org > <mailto:jakub.kahovec-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>> wrote: > > Hello, > I was thinking about doing an alphabetical navigation for i.e list of > users (there would be alphabet at the top of the list and by > clicking on > a character the list would get filtered). > I did some googling but didn''t find any plugin or quick hack sorting > this problem out. It''s however such a common thing that I was > wondering > whether there isn''t really some. > Any suggestions or ideas are very welcome > Thanks > Jakub > > -- > There is only one success - to be able to spend your life in your > own way. > > > > > > --~--~---------~--~----~------------~-------~--~----~ > 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 > -~----------~----~----~----~------~----~------~--~--- >-- There is only one success - to be able to spend your life in your own way.