Tom
Tom

Reputation: 4087

Customize Rails Routes

In routes.rb i've declared:

resources :photos

How can i map the /photos/new route with /admins/photos/new? With namespaces?

Thanks

Upvotes: 0

Views: 53

Answers (2)

Mike Campbell
Mike Campbell

Reputation: 7978

See Chapter 2.6 of Rails Routing Guide.

You may wish to organize groups of controllers under a namespace. Most commonly, you might group a number of administrative controllers under an Admin:: namespace. You would place these controllers under the app/controllers/admin directory, and you can group them together in your router:

namespace :admin do
  resources :posts, :comments
end

Upvotes: 2

Amir
Amir

Reputation: 1872

That's right. You can use:

namespace :admin do
  resources :photos
end

Upvotes: 0

Related Questions