?

Log in

Wed, Oct. 17th, 2007, 12:30 pm
joeylemur: Fun with REST routing

So, I have a Users controller, that I want to have some user-level methods in, and I want to separate administrative stuff out to a Users::Admin controller.

My routes are set up:

map.resources :users
map.resources :usersadmin, :controller => 'users/admin'

This works... but its ugly. I want to be able to put in 'http://localhost:3000/users/admin' to get at the admin page, but as this is set up, I have to put in 'http://localhost:3000/usersadmin'. I can't figure out how to convince the routing to let me map REST methods to /users/admin.

Anyone have any ideas?

Wed, Oct. 17th, 2007 05:52 pm (UTC)
texasjusticar

map.connect "/users/admin/:action", :controller=>'useradmin'

I haven't done much restful routing, but the above is what I would use in Rails < 1.2.4

Thu, Oct. 18th, 2007 04:30 pm (UTC)
qaexl

Wouldn't it make more sense to use admin/users instead of users/admin ?

Under Edge and 2.0PR, you can use namespaced resources.

-Q

Thu, Oct. 18th, 2007 09:26 pm (UTC)
joeylemur

I had thought about it... I suppose I could work it like that, but... enh. Wasn't how I had planned things out. :)

Fri, Oct. 19th, 2007 02:50 am (UTC)
qaexl

Guess so.

-Q