Open hachpai opened 9 years ago
I'm not sure why you're getting that behavior... the DSL is still a tad buggy, in my opinion. Can you try changing your code to
has_permission on :admin_users, :to=> [:update, :show, :edit] do
if_attribute :test_method => true
if_attribute :id => is {user.id}
end
and post the result? In my experience sometimes things in the DSL that should be DRY start acting strangely. In the meantime I'll see if I can figure this out... Oh, and would you mind posting your controller as well? Don't forget that you have to set :attribute_check => true
Edit: I just noticed that your post was from 6 months ago... sorry for the late reply!
Hello,
I've the following rule:
test_method is defined like that:
If I try to access the /admin/user page, the rule is well taken in consideration, I can change the return of test_method from true to false and permit seems to make his work correctly because I get the form if true and redirected to access_denied if false.
But if I try to make
(notice: I must set the context because my user controller is in an admin module) This fails :
I get 't' or 'f', depending of the return value of the method.
But if I reverse the rule like this:
The access to the page still depends of the return value of test_method, but the with_permission_to doesn't fail and just ignore the first method part of the rule and only consider the "id is user.id" condition attribute.
I do that because I would like to define methods who would perform SQL queries to define hierarchical access rules.
Thank you for you work and future help,
PH