[英]CanCan is not allowing custom action/pages in Spree backend
我在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
謝謝你的幫助。
我通過重寫collection_actions並添加了我需要工作的動作來解決這個問題-
def collection_actions
[:index, :clean, :repair, :colour]
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.