本文介绍了CanCan::Ability 在哪里定义了 current_user 方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
几乎我在标题中提到的内容.我在我的代码中使用 CanCan::Ability 来检查权限和能力.它需要定义一个 current_user 方法.我猜它来自设计(但不确定),我希望覆盖它.最好的方法是什么?
Pretty much what I have mentioned in the title. I am using CanCan::Ability in my code to check permissions and abilities. It expects a current_user method to be defined. I am guessing it comes from devise (but not sure), and I wish to override it. Whats the best way to do that?
推荐答案
找到了 此处 在源代码中.不过,这与设计无关.文档位于方法上方并描述了如何覆盖它.
It's found here in the source code. It's nothing to do with devise, though. The documentation is found above the method and describes overwriting it.
这篇关于CanCan::Ability 在哪里定义了 current_user 方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!