Rails 4: Grouping Controllers in a folder
ruby-on-rails
Solution
If you execute `rake routes`, you will notice the names of all your controllers is prefixed with 'admin/'.
Because you move your controllers to directory "admin", you should add a namespace to each controller there. For example:
class Admin::AdminMainController < ActionController::Base
end
And check your controllers, views and helpers, update all relevant paths and controller's names.
Problem
I would like to group all my controllers and their views in folders for example under "admin" This what I did: (1) I moved all the `controllers` under a folder `admin` (2) I moved all the `views` under a folder `admin` (3) I read in Rails Guide that I should be doing this: ``` scope module: 'admin' do resources :admin_permissions, :admin_layout, :admin_db end ``` but I keep getting an error ``` ActionController::RoutingError at /admin_permissions/index uninitialized constant AdminMainController ``` Directory Structure: ``` controllers -> admin -> admin_main_controller -> admin_permissions_controller -> admin_layouts_controller -> admin_db_controller views -> admin -> admin_main -> admin_permissions -> admin_layouts -> admin_db ``` All first three controllers inherit from admin_main which inherits from application Any advise on what to read/check?