Rails: Pundit::AuthorizationNotPerformedError
Rails: Pundit::AuthorizationNotPerformedError
我尝试安装专家。但是当我设置 gem 时,我收到了这条消息。
我不是很懂。我是 user.admin 可能有冲突吗?谢谢你的回答。
Pundit 向您的控制器添加了一个名为 verify_authorized
的方法,它确保 authorize
方法在您的控制器操作中的某处被调用。您可能设置了一个调用 verify_authorized
(https://github.com/elabs/pundit#ensuring-policies-and-scopes-are-used) 的 after_action
。确保通过控制器操作在每个可能的执行路径中调用 authorize
。
或者,如果您不想授权该特定操作,您可以跳过它:
class PagesControler < ApplicationController
include Pundit
after_action :verify_authorized, except: [:home]
...
end
或者如果您在继承的控制器中设置 after_action
:
class ApplicationController < ActionController::Base
include Pundit
after_action :verify_authorized
...
end
class PagesControler < ApplicationController
skip_after_action :verify_authorized, only: [:home]
...
end
我尝试安装专家。但是当我设置 gem 时,我收到了这条消息。
我不是很懂。我是 user.admin 可能有冲突吗?谢谢你的回答。
Pundit 向您的控制器添加了一个名为 verify_authorized
的方法,它确保 authorize
方法在您的控制器操作中的某处被调用。您可能设置了一个调用 verify_authorized
(https://github.com/elabs/pundit#ensuring-policies-and-scopes-are-used) 的 after_action
。确保通过控制器操作在每个可能的执行路径中调用 authorize
。
或者,如果您不想授权该特定操作,您可以跳过它:
class PagesControler < ApplicationController
include Pundit
after_action :verify_authorized, except: [:home]
...
end
或者如果您在继承的控制器中设置 after_action
:
class ApplicationController < ActionController::Base
include Pundit
after_action :verify_authorized
...
end
class PagesControler < ApplicationController
skip_after_action :verify_authorized, only: [:home]
...
end