rails/rails — Issue #4855: Strange behavior with namespace
Author: diegorv
Created: 2012-02-02 18:47:00+00:00
State: open

My env:

gem 'rails', '3.2.1'
ruby 1.9.3-p0

My route files:

namespace :manager do
resources :stores do
resources :categories
end
end

or

resources :stores, :module => "manager" do
resources :categories
end

This is my 'rake routes' command

manager_store_categories GET /manager/stores/:store_id/categories(.:format) manager/categories#index
POST /manager/stores/:store_id/categories(.:format) manager/categories#create
new_manager_store_category GET /manager/stores/:store_id/categories/new(.:format) manager/categories#new
edit_manager_store_category GET /manager/stores/:store_id/categories/:id/edit(.:format) manager/categories#edit
manager_store_category GET /manager/stores/:store_id/categories/:id(.:format) manager/categories#show
PUT /manager/stores/:store_id/categories/:id(.:format) manager/categories#update
DELETE /manager/stores/:store_id/categories/:id(.:format) manager/categories#destroy
manager_stores GET /manager/stores(.:format) manager/stores#index
POST /manager/stores(.:format) manager/stores#create
new_manager_store GET /manager/stores/new(.:format) manager/stores#new
edit_manager_store GET /manager/stores/:id/edit(.:format) manager/stores#edit
manager_store GET /manager/stores/:id(.:format) manager/stores#show
PUT /manager/stores/:id(.:format) manager/stores#update
DELETE /manager/stores/:id(.:format) manager/stores#destroy

But when i try http://localhost:3000/manager/stores

Rails are looking for controller "StoresController" without namespace "Manager::", but the nested resources :categories are looking for namespace "Manager::"

So to make this code work i need the controller manager/categories_controller.rb like:

class Manager::CategoriesController < ApplicationController
end

and the stores_controller.rb outside namespace "manager" like:

class StoresController < ApplicationController
end