I have create a new role in Spree and limited it with CanCan to only one controller. However it does not allow access to custom actions/pages.
create, delete, index etc
The above actions are accessible, yet my 'clean' view is not.
Controller -
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)
Also tried -
can [:clean, :admin, :index etc..], Spree::Handbag
Thanks for any help.
I got around this by overriding collection_actions and adding the actions I needed to work -
def collection_actions
[:index, :clean, :repair, :colour]
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.