1

我的授权规则:

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

为什么我仍然获得拒绝许可?我试过玩,但我仍然无法获得当前用户,这是一个编辑自己个人资料的测试人员。

4

1 回答 1

0

您可能需要将授权规则更改为:

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

我猜那个用户没有名为用户的属性,这就是你原来的例子失败的原因。您必须将用户的 id 与当前用户的 id 进行比较。

于 2011-03-03T07:42:16.677 回答