Ruby on rails Spree-I';我可以在管理面板中看到我的选项卡,但授权失败消息闪烁
我正在为Spree创建一个扩展。它允许多个商店,所以我在管理区添加了一个面板 我还创建了一个新角色:商店 我创建了一个AbilityDecorator,如下所示Ruby on rails Spree-I';我可以在管理面板中看到我的选项卡,但授权失败消息闪烁,ruby-on-rails,ruby,authorization,cancan,spree,Ruby On Rails,Ruby,Authorization,Cancan,Spree,我正在为Spree创建一个扩展。它允许多个商店,所以我在管理区添加了一个面板 我还创建了一个新角色:商店 我创建了一个AbilityDecorator,如下所示 module Spree class AbilityDecorator include CanCan::Ability def initialize(user) if user.respond_to?(:has_spree_role?) && user.has_spree_role?(
module Spree
class AbilityDecorator
include CanCan::Ability
def initialize(user)
if user.respond_to?(:has_spree_role?) && user.has_spree_role?('store')
can :admin, Store
end
end
end
Ability.register_ability(AbilityDecorator)
end
问题是,我可以访问与商店用户登录的管理区域。它只显示“存储”选项卡。但我被重定向到/admin/authorization\u失败,错误消失
有什么想法吗
更新:
我需要在我的装饰器中添加以下行:
can [:admin, :index, :show], Order
因为/admin被路由到orders#u controller#索引