2013-07-26 4 views
0

rails_admin, devise 및 cancan을 사용하고 있습니다.has_many에 대한 옵션을 선택할 수 없습니다.

사용자는 많은 역할을합니다.

관리자 역할을 가진 사용자가 사용자를 관리 할 수있는 관리자 페이지가 설정되어 있습니다. 그러나 관리자는 역할을 관리 할 수 ​​없습니다.

사용자를 만들거나 편집 할 때 역할이 나열되지 않습니다.

관리자가 역할을 편집하거나 만들도록 허용하지 않고 어떻게 사용자에게 역할을 추가하도록 허용합니까?

내 능력 파일

class Ability 
    include CanCan::Ability 

    def initialize user 
    if user && user.admin? 
     can :access, :rails_admin 
     can :dashboard 
     cannot :manage, Role 
     can :manage, User 
    else 
     cannot :access, :rails_admin 
    end 
    end 
end 

내가 명시 적으로 rails_admin의 설정에서 연결 범위를 재정의하는 시도이다, 그러나 그것은 전혀 도움이되지 않았다 :

field :role do 
    associated_collection_scope do 
     Proc.new do |scope| 
     scope = scope 
     end 
    end 
    end 

답변

0

나는 그것을 만들 수 있었다 can :index, Role을 추가하여 작동하지만 사이드 바에 역할을 표시하므로 실제로 원하지 않습니다.

class Ability 
    include CanCan::Ability 

    def initialize user 
    if user && user.admin? 
     can :access, :rails_admin 
     can :dashboard 
     can :index, Role 
     can :manage, User 
    else 
     cannot :access, :rails_admin 
    end 
    end 
end 
+0

'rails_admin.rb'의'config.excluded_models'에 역할을 추가하면 원치 않는 색인 페이지와 탐색 항목이 숨겨집니다. – BM5k

관련 문제