【发布时间】:2015-10-22 16:41:44
【问题描述】:
我在 Spree 中创建了一个新角色,并使用 CanCan 将其限制为只有一个控制器。但是它不允许访问自定义操作/页面。
create, delete, index etc
上述操作可以访问,但我的“干净”视图不是。
控制器 -
def clean
@handbags = Spree::Handbag.is_clean.page(params[:page]).per(50)
end
AbilityDecorator -
class AbilityDecorator
include CanCan::Ability
def initialize(user)
if user.respond_to?(:has_spree_role?) && user.has_spree_role?('technical')
can :manage, Spree::Handbag
end
end
end
Spree::Ability.register_ability(AbilityDecorator)
也试过了-
can [:clean, :admin, :index etc..], Spree::Handbag
感谢您的帮助。
【问题讨论】:
标签: ruby-on-rails devise cancan spree