Reputation: 623
I have an application that I want to have a route that is /admin/active_vulnerabilities but when I generate the controller as rails generate controller ActiveVulnerabilities
and put the following in my routes.rb
namespace :admin do
resources :users
resources :active_vulnerabilities
# Admin root
root to: 'application#index'
end
But I get the error uninitialized constant Admin::ActiveVulnerabilitiesController
so I changed my controller to class Admin::ActiveVulnerabilitiesController < ApplicationController
I then get the error Unable to autoload constant ActiveVulnerabilitiesController, expected /home/luke/projects/vuln_frontend/app/controllers/active_vulnerabilities_controller.rb to define it
but the file mentioned is my controller named exactly as that.
Upvotes: 0
Views: 215
Reputation: 30071
Your controller should be put in app/controllers/admin/
because the namespace. Otherwise, you can forget this directory and the namespace and use just scope
scope :admin do
resources :active_vulnerabilities
end
class ActiveVulnerabilitiesController < ApplicationController
Upvotes: 1