1
다음은 코드입니다. 그것의 모양에서 CanCan + Devise : 관리자 권한이 있어도 관리자 권한을 얻을 수 없습니다.
class ApplicationController < ActionController::Base
...
check_authorization :unless => :do_not_check_authorization?
private
def do_not_check_authorization?
respond_to?(:devise_controller?)
end
end
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
if user.role? == "admin"
can :manage, :all
elsif user.role? == "developer"
can :manage, :websites
can :manage, :pages
can :manage, :templates
elsif user.role? == "editor"
can :manage, :pages
end
end
end
class WebsitesController < ApplicationController
load_and_authorize_resource
...
end
, 관리 역할이있는 사용자 때문에
can :manage, :all
의 웹 사이트 컨트롤러와 아무것도 할 수 있어야합니다.
하지만 웹 사이트/색인을 쳤을 때, 나는
CanCan::AccessDenied in WebsitesController#index
You are not authorized to access this page.
왜 이런 일이 얻을?
안녕하세요! 'rolify '와 같은 것을 사용하여 사용자의 역할을 관리하고 있습니까? – jvnill
@jvnill, 나는 내 문제를 해결했다. 아래 답변에서 내 바보 같은 실수를 참조하십시오. –