I am trying to define a namespace as admin and my routes file is the following;
namespace :admin do
root 'base#index'
resources :boats
end
So I have admin folder, and inside I have base_controller.rb
;
class Admin::BaseController < ApplicationController
before_action :logged_in_user, :auth_admin
def index
end
end
and I created cars_controller.rb inherited from BaseController;
class Admin::CarsController < BaseController
def index
@cars = Car.all
end
end
So, like this I get error from the console;
ActionController::RoutingError (uninitialized constant BaseController):
app/controllers/admin/cars_controller.rb:1:in `<top (required)>'
If I change instead of BaseController to ApplicationController, it works without a problem. Bur I could not figured it out why it gives such error.
ActionController::RoutingError (uninitialized constant BaseController):
Your BaseController
is inherited from Admin
, so you need to write Admin::BaseController
instead of BaseController
class Admin::CarsController < Admin::BaseController
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.