Pundit::AuthorizationNotPerformedError

依然范特西╮ 提交于 2019-12-30 09:17:10

问题


I try install pundit. But when I set up the gem I have this message.

error message

I don't really understand. I am user.admin maybe is there a conflict? Thank you for your answer.


回答1:


Pundit adds a method to your controller called verify_authorized that ensures that the authorize method is called somewhere in your controller action. You likely setup an after_action that calls verify_authorized (https://github.com/elabs/pundit#ensuring-policies-and-scopes-are-used). Make sure you're calling authorize in each possible execution path through your controller action.

Alternatively, if you do not want to authorize that particular action, you can skip it:

class PagesControler < ApplicationController
  include Pundit
  after_action :verify_authorized, except: [:home]

  ...
end

or if you setup the after_action in an inherited controller:

class ApplicationController < ActionController::Base
  include Pundit
  after_action :verify_authorized

  ...
end

class PagesControler < ApplicationController
  skip_after_action :verify_authorized, only: [:home]

  ...
end


来源:https://stackoverflow.com/questions/35071428/punditauthorizationnotperformederror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!