0
我希望管理员用户无法创建具有超级管理员角色的用户,但仍能够创建其他管理员和常规用户。我该如何做到这一点?这里是我的Ability.rb:只允许使用CanCanCan创建受限用户
class Ability
include CanCan::Ability
def initialize(user)
if user.super_admin?
can :manage, :all
elsif user.admin?
can :manage, [Article, Comment]
can [:destroy, :update], User, :role_id => 2 # If Admin
can [:destroy, :update], User, :role_id => 3 # If User
can :read, User
can :create, User
elsif user.user_regular?
#cannot :read, ActiveAdmin::Page, :name => "Dashboard"
#can :manage, :all
end
end
end