最佳答案
Pundit 向您的 Controller 添加了一个名为 verify_authorized
的方法,以确保在您的 Controller 操作中的某处调用了 authorize
方法。您可能设置了一个调用 verify_authorized
( https://github.com/elabs/pundit#ensuring-policies-and-scopes-are-used ) 的 after_action
。确保通过 Controller 操作在每个可能的执行路径中调用 authorize
。
或者,如果您不想授权该特定操作,您可以跳过它:
class PagesControler < ApplicationController
include Pundit
after_action :verify_authorized, except: [:home]
...
end
或者如果您在继承的 Controller 中设置after_action
:
class ApplicationController < ActionController::Base
include Pundit
after_action :verify_authorized
...
end
class PagesControler < ApplicationController
skip_after_action :verify_authorized, only: [:home]
...
end
关于ruby-on-rails - Rails 中的 Pundit::AuthorizationNotPerformedError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35071428/