I have this in my routes.db, in its entirety map.resources :posts, :users map.connect '''', :controller => ''posts'' map.connect ''users/:page'', :controller => ''users'', :action => ''index'', :requirements => { :page => /\d+/} map.connect ''users/:id/:page'', :requirements => { :id => /[a-z]+/i, :page => /\d+/}, :controller => ''users'', :action => ''show'' map.connect '':controller/:action/:id.:format'' map.connect '':controller/:action/:id'' /users/admin/2 goes to page 2 of the user ''admin'' as expected. and / users go to the users index page. however, /users/2 shows user with id#2, and not page 2 of the users index. I have in my user model def to_param self.name end and name is never all digits. seems like it should work. why doesn''t it? thanks. --~--~---------~--~----~------------~-------~--~----~ 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 3 Dec 2007, at 15:04, rubynuby wrote:> > I have this in my routes.db, in its entirety > > map.resources :posts, :users > map.connect '''', :controller => ''posts'' > > map.connect ''users/:page'', > :controller => ''users'', > :action => ''index'', > :requirements => { :page => /\d+/} > > > /users/admin/2 goes to page 2 of the user ''admin'' as expected. and / > users go to the users index page. > > however, /users/2 shows user with id#2, and not page 2 of the users > index. I have in my user model > seems like it should work. why doesn''t it? thanks.Well map.resources :users will add a route mapping users/2 to the user with id 2. Since it''s higher up in your routes file it will get priority Fred. --~--~---------~--~----~------------~-------~--~----~ 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 3, 8:29 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 3 Dec 2007, at 15:04, rubynuby wrote: > > > > > > > > > I have this in my routes.db, in its entirety > > > map.resources :posts, :users > > map.connect '''', :controller => ''posts'' > > > map.connect ''users/:page'', > > :controller => ''users'', > > :action => ''index'', > > :requirements => { :page => /\d+/} > > > /users/admin/2 goes to page 2 of the user ''admin'' as expected. and / > > users go to the users index page. > > > however, /users/2 shows user with id#2, and not page 2 of the users > > index. I have in my user model > > seems like it should work. why doesn''t it? thanks. > > Well map.resources :users will add a route mapping users/2 to the user > with id 2. > Since it''s higher up in your routes file it will get priority > > Fred.Moving map.resources :users down below didn''t help. in fact, taking it out altogether didn''t help. users/2 still shows user with id#2. oddly enough, it still understands users/admin. I cleared cache and restarted server. --~--~---------~--~----~------------~-------~--~----~ 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 3, 11:37 am, rubynuby <dear...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 3, 8:29 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > > > On 3 Dec 2007, at 15:04, rubynuby wrote: > > > > I have this in my routes.db, in its entirety > > > > map.resources :posts, :users > > > map.connect '''', :controller => ''posts'' > > > > map.connect ''users/:page'', > > > :controller => ''users'', > > > :action => ''index'', > > > :requirements => { :page => /\d+/} > > > > /users/admin/2 goes to page 2 of the user ''admin'' as expected. and / > > > users go to the users index page. > > > > however, /users/2 shows user with id#2, and not page 2 of the users > > > index. I have in my user model > > > seems like it should work. why doesn''t it? thanks. > > > Well map.resources :users will add a route mapping users/2 to the user > > with id 2. > > Since it''s higher up in your routes file it will get priority > > > Fred. > > Moving map.resources :users down below didn''t help. in fact, taking > it out altogether didn''t help. users/2 still shows user with id#2. > oddly enough, it still understands users/admin. I cleared cache and > restarted server.D''OH! I''m an idiot. there''s a map.resources :users right at the top which I did not see b/c of all the comments. it''s all good now. for those interested, here''s my routes which works well with will_paginate and probably other pagination # posts is my default controller map.connect '''', :controller => ''posts'' map.connect '':page'', :action => ''index'', :controller => ''posts'', :requirements => { :page => /\d+/}, :page => nil map.connect '':controller/:page'', :action => ''index'', :requirements => { :page => /\d+/} # needs to be adjusted if your ID is all numeric map.connect '':controller/:id/:page'', :action => ''show'', :requirements => { :id => /[a-z]+/i, :page => /\d+/}, :page => nil map.connect '':controller/:action/:id/:page'', :requirements => { :page => /\d+/}, :page => nil map.resources :posts, :inkers map.connect '':controller/:action/:id.:format'' map.connect '':controller/:action/:id'' --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---