-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rules for index actions not working as expected. #5
Comments
Hi Fatih, I'll like to ask you one question before investigate a bit more, do you want this rule to be executed on 'index' and 'show' actions or only on 'show' action ? Cheers, |
Hi Tortue, I think you are going to say to have different rules for show and index actions. Am I right? I always use cancan when I develop with Rails. Cancan automatically omits the code part of the rule. So I expect that authority-controller has this feature too. |
Yes, you are. |
I can confirm you this is an issue, thank you for reporting it 😉
The CanCan doc for this behavior is here. So I need to port this doc. Before I fix this issue, you can use this workaround in your Authority-Controller if($user->hasRole('admin')) {
$authority->allow('show', 'Actor', function($self, $actor){
return $actor->id >= 3;
});
} |
@computeus To confirm that this issue is gone, can you update this package in your application ? {
// ...
"require": {
//...
"efficiently/authority-controller": "dev-master",
//...
} Then update it, like this: If you have still the error, reopen this issue please. Otherwise, if it's OK, I'll tag a new version. Have a good day, |
@tortuetorche Index action works as expected but now show action is broken. The conditional callback of the rule is not executed with show action. Thanks for your effords. |
My bad, I need to check this. |
@computeus You're welcome Can you update this package and try again, please ? |
It works as expected. Thank you very much. |
🆒 |
Hi,
I have written a rule like this,
On index action of ActorController, I get an error 'Trying to get property of non-object' as the error is displayed for the
line as there is no $actor object on the index action. But why is the function defined in rule definition executed when I visited the index action as the README says the opposite?
The text was updated successfully, but these errors were encountered: