0

私は宣言による認可宝石を使用して、私のauthorization_rules.rbに、私はルールを次ています宣言的承認 - コントローラ内のすべてのアクションに対するアクセスを設定する方法?

role :admin do 
    has_permission_on :users, :to => [manually set up all actions in this controller] 
    end 

は、それぞれのコントローラにすべてのアクションへのアクセスをセットアップするための任意のよりエレガントな方法が存在するの?私はこれらの方法に

role :admin do 
    has_permission_on :users, :to => :all 
    end 

    role :admin do 
    has_permission_on :users 
    end 

を試みたが、何も私を働きません。コントローラーにすべてのアクションを設定するより良い方法は、すべてのアクションを怠惰に入力するよりもありますか?

答えて

0

アクションはコントローラクラスのパブリックメソッドです。下記のコードはテストされていませんが、あなたを始めてください。

c = MyController 
actions = [] 
c.public_methods(false).each { |m| actions << m.to_sym } 

role :admin do 
    has_permission_on :users, :to => actions 
end 
0

これは私が何をすべきかです:

has_permission_on :controller, :to => [:all] 
関連する問題