==> I have a website with two names spaces as below
User::xyz_controller
User::abc_controller
Admin:xyz_controller
Admin:abc_controller
==> User model with three roles
admin
leader
consultant
If the user has role leader or consultant. He should only access the User namespace controllers. and if User has role Admin. Admin should only access the Admin namespace controllers.
==> below is my ability.rb file content.
class Ability
include CanCan::Ability
def initialize(user)
if user.has_role? :Admin
can :manage, :all
elsif user.has_role? :Leader
cannot :manage, User
elsif user.has_role? :Consultant
cannot :manage, User
end
end
end