How to access 'can?' method from within cell?

后端 未结 2 1710
猫巷女王i
猫巷女王i 2021-02-09 08:30

I\'m using cancan and cells gems in my ruby-on-rails project. How to access can? method from within cell? Thanks.

2条回答
  •  轮回少年
    2021-02-09 09:31

    For those who happen to have a custom current_ability() method (in which you can change the name of current_user method and Ability class names):

    class OrderCell < Cell::Rails
      include CanCan::ControllerAdditions
      delegate :current_ability, :to => :controller
    end
    

提交回复
热议问题