tybro0103
tybro0103

Reputation: 49743

Rails namespace with path name different than module name

I'd like to have a namespace in Rails where the module name in code is different than the path name that user sees in the URL.

One can make a namespace in routes like so:

namespace :admin_ui do
  resources :posts
end

and this will match /admin_ui/posts to AdminUI::PostsController.

How can I make this namespace match the path /admin, but use module AdminUI?

Upvotes: 7

Views: 3258

Answers (1)

tybro0103
tybro0103

Reputation: 49743

Found it:

namespace :admin_ui, path: 'admin' do
  resources :posts
end

Upvotes: 12

Related Questions