Pundit
的 authorize
有 3 个参数,但在 Controller 中你只需要传递 2 个参数,current_user 会自动传递。 current_user
是如何传递的?
我查看了 Pundit 的代码,但无法弄明白。
最佳答案
来自 pundit readme :
The first argument is a user. In your controller, Pundit will call the current_user method to retrieve what to send into this argument
来自 pundit.rb文件:
def pundit_user
current_user
end
关于ruby-on-rails - Pundit 如何将 current_user 传递给授权方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48085122/