REST & Routing: namespaces within resources

I know I can use a namespace on the map passed into the block for ActionController::Routing::Routes.draw because I've done that with some Admin:: controllers.

What I want to do is something similar with controllers for resources that belong to another resource.

Is it possible to do something like this:

map.resources :shops do |shop|

  shop.resource :shopkeeper

  shop.namespace |goods| do     goods.resources :sweets     goods.resources :beer     goods.resources :shoes   end


so that I can have URLs like

/shops/123/goods/sweets /shops/123/goods/beer

and controllers like

Goods::SweetsController Goods::ShoesController

I had a go at this but it doesn't seem to work - and I thought I'd ask whether it was possible before I waste too much time on it.

That should work, just correct your namespace definition:

shop.namespace :goods do |goods|   goods.resources :sweets   goods.resources :beer   goods.resources :shoes end