Why don't these routes work

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.

On 3 Dec 2007, at 15:04, rubynuby wrote:

/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.

On Dec 3, 8:29 am, Frederick C. [email protected]
wrote:

map.resources :posts, :users
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.

On Dec 3, 11:37 am, rubynuby [email protected] wrote:

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’

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs