I have an admin namespace as such:
namespace :admin do
resources :users
resources :base
end
With the following directory structure:
/app/controllers/
+ admin
- base_controller.rb
- users_controller.rb
- users_controller.rb
- application_controller.rb
I have to wrap admin/users_conroller.rb in a module Admin end, otherwise I get an Uninitialized constant BaseController error:
class Admin::BaseController < ApplicationController
end
# Works fine
module Admin
class UsersController < BaseController
end
end
# Breaks with error
class Admin::UsersController < BaseController
end
Any idea why this is happening? Using Rails 3.2.
Namespaces map to directories, underscored filenames are camelcased for class names.
needs to be in
app/controllers/some/deeply_nested/base_actions_controller.rbfor rails to find it.In your code, there is no
app/controllers/base_controller.rb, soBaseControllerinpoints to no class Rails knows about. You need to give it the admin namespace (as your class definition for BaseController also has)
The above and your working code from your Question are one in the same