2016-12-07 1 views
0

관리자 권한을 가진 사용자를 수퍼 관리자 권한으로 만들 수 없지만 다른 관리자 및 일반 사용자는 계속 만들 수 있기를 바랍니다. 어떻게해야합니까?CanCanCan에서만 제한된 사용자 생성 허용

사용 cannot
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 

답변

0

cannot :creat, User, :role_id => 1 # let 1 is super admin role id 같은 admin 블록과 : 여기 내 Ability.rb입니다. 결합 능력에 대한 자세한 정보를 얻을 수 있습니다 at here

관련 문제