A very simple user model, I want the administrator: to manage all
else cannot: index, user, and some other parameters, but when I try to block non-admin users from viewing the user index, the admin user also does not have access.
this is my ability .rb
class Ability include CanCan::Ability def initialize(user) user ||= User.new #guest user can :manage, :all if user.role == "admin" #if user.admin? can :manage, :all can :assign_role, User else can :read, :all can :create, User cannot :assign_role, User cannot :index, User can [:show, :edit, :update], User do |current_user| user.id == current_user.id || user.role == "admin" end end end
What can I do to block all users from user index?
Hi
Dan
source share