安装pundit后尝试创建用户时出错

时间:2019-02-19 20:53:21

标签: ruby-on-rails ruby pundit

在项目中安装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

0 个答案:

没有答案