Pundit如何将current_user传递给authorize方法?

3

Punditauthorize方法需要传入3个参数,但在控制器中只需要传入2个,因为current_user会被自动传递。那么current_user是如何传递的呢? 我查看了Pundit的代码,但是没有弄清楚。

1个回答

2

来自 pundit readme:

第一个参数是用户。在您的控制器中,Pundit将调用current_user方法来检索要发送到此参数的内容。

来自pundit.rb文件:

def pundit_user
  current_user
end

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接