0

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.

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

I moved the controller to app/controllers/admin/ and edited the routes file to show namespace :admin do resources :users resources :activevulnerabilities # Admin root root to: 'application#index' end but I still get the same issue
Try to restart the server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.