如何访问’可以吗?’ 细胞内的方法?

我在ruby-on-rails项目中使用了cancancells gem。 如何访问can? 细胞内的方法? 谢谢。

我必须做到这一点。 尝试

 class MyCell < Cell::Rails include CanCan::ControllerAdditions end 

如果你也在使用Devise,我必须这样做:

 class MyCell < Cell::Rails include CanCan::ControllerAdditions include Devise::Controllers::Helpers Devise::Controllers::Helpers.define_helpers(Devise::Mapping.new(:user, {})) end 

#define_helpers会添加辅助方法,如current_user和user_signed_in? 到细胞。

对于那些碰巧有自定义current_ability()方法的人(可以在其中更改current_user方法和Ability类名称的名称):

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