-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Namespaced policy and controller can't find authorization target for index #170
Comments
I recently upgraded my rails version to 6.1.3.2 and I have started getting similar error:
I'm using |
Hey @ingnam! That looks like a different problem: Could you please open a separate issue in https://github.com/palkan/action_policy-graphql ? |
@robbevp The problem is that What if you add authorize! Report (What surprises me more is that an array with exception message is passed as implicit target 🤔 it should raise an exception (unless |
@robbevp Could you please take a look at the question above? |
Hi @palkan If I add the class as an argument, everything works as expected. |
Hm, interesting; could you share the results of the following expression (executed right before
|
The сontroller_name: reports
сontroller_name.classify: Report But constantizing throws Is there a way to make this work with action_policy (without explictly mentioning the model on |
Ok, that's the answer. You can override the def implicit_authorization_target
controller_path.classify.safe_constantize
end |
thankyou |
Tell us about your environment
Ruby Version: 3.0.1
Framework Version (Rails, whatever): Rails 6.1.3.1
Action Policy Version: 0.5.7
What did you do?
I created a controller and namespaced policy very similar to the example of nested modules in the docs.
My controller (simplified)
My policy
What did you expect to happen?
When calling either index or show, I expect the corresponding policy to be called.
What actually happened?
When calling show, the policy is found and correctly called. When calling index, i get the following error
Any help? Since nested namespaces with an index action are mention explicitly in the docs, I thought that I should need to explicitly provde the authorization target
The text was updated successfully, but these errors were encountered: