在项目中安装pundit后,尝试创建新用户时,都会出现以下错误。即使我安装了它并包括了gem并运行了捆绑安装程序,它似乎也找不到pundit。
app_1 | ActionController::RoutingError (uninitialized constant ApplicationController::Pundit):
app_1 |
app_1 | app/controllers/application_controller.rb:3:in `<class:ApplicationController>'
app_1 | app/controllers/application_controller.rb:1:in `<top (required)>'
app_1 | app/controllers/v1/users_controller.rb:1:in `<top (required)>'
我的ApplicationController.rb
class ApplicationController < ActionController::API
before_action :authenticate_user!
include Pundit
after_action :verify_authorized, except: :index, unless: :skip_pundit?
after_action :verify_policy_scoped, only: :index, unless: :skip_pundit?
private
def skip_pundit?
devise_controller? || params[:controller] =~ /(^(rails_)?admin)|(^pages$)/
end
end