2011-03-03 45 views
1

我的授权规则:声明AUTH问题if_attribute

role :tester do 
    has_permission_on [:regression_test_test_runs, :regression_test_jobs], :to => :manage 
    has_permission_on [:authorization_rules], :to => [:read, :manage] 
    has_permission_on [:users], :to => :edit do 
    if_attribute :user => is {user} 
    end 
end 

我的用户控制器

filter_access_to :all, :attribute_check => true 

那为什么我仍然得到一个权限被拒绝?我尝试过玩,我仍然无法得到当前用户,这是一个测试人员编辑他自己的配置文件。

回答

0

你可能需要改变你的授权规则:

role :tester do 
    ... 
    has_permission_on [:users], :to => :edit do 
    if_attribute :id => is {user.id} 
    end 
end 

我猜,用户不具有的属性指定的用户,这就是为什么你原来的例子是失败。您必须将用户的ID与当前用户的ID进行比较。