routes ressources and namespace

Hi all,
I created a namespace for my categories resource. I removed the show action because otherwise I would get this kind of route for my show action: /admin/categories/:id

namespace :admin do

resources :categories, :except => :show

end

What I want for the show action is a route like this: **/categories/:name **

I achieved this with the help of this mapping:

match ‘categories/:name’ => ‘admin/categories#show’, :as => :category

But now I’m wondering if this could also be configured in the same way in the namespace/resource configuration?

What’s also strange that if I remove the admin from the matched route (match …. => 'categories#show) I got the following error:

uninitialized constant CategoriesController

Is this because I added an except for the show method in the resources configuration?

Is my matched route a correct way of solving my problem with the route or is there another way?

Thanks for your help.

Cheers Greg

Hi Greg,

Its one of the way to change the name space.

Regarding the error:

Categories controller might have been under admin module.

If you check app/controllers/admin, you will c categories controller.

The routes - match 'categories/:name' => 'admin/categories#show', :as =>
:category

goes to admin->categories controller.

If you change this to be like this,

match 'categories/:name' => 'categories#show', :as => :category

It searches for categories controller which is not present..

Regards,

Angel

Greg wrote in post #1061118:

Hi Angel,
you are right the error occurs because my categories controller is under admin/categories_controller. Now the error makes sense.

Regards the configuration of my route. I think I will leave it as it is because it's working how I expect it.

Cheers Greg