-
-
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
authorize! with no arguments not resolving namespace #14
Comments
Should work with I've tried to reproduce it here: https://github.com/palkan/action_policy/tree/repro/14/tmp/issue14-app. Works as expected. How does it differ from your setup? Also, while I was trying to reproduce the problem I also faced the same issue; it turned out that I had a type in policy file name. Could you try to run |
Hi @palkan, thanks for your reply! I did what you suggested: Loading development environment (Rails 5.2.0.rc2)
# AnnouncementPolicy in policies/
irb(main):001:0> "Groups::AnnouncementPolicy".safe_constantize
=> nil
irb(main):002:0> reload!
Reloading...
=> true
# Groups::AnnouncementPolicy in policies/
irb(main):003:0> "Groups::AnnouncementPolicy".safe_constantize
LoadError: Unable to autoload constant AnnouncementPolicy, expected /app/app/policies/announcement_policy.rb to define it
from (irb):3
irb(main):004:0> reload!
Reloading...
=> true
# Groups::AnnouncementPolicy in policies/groups/
irb(main):005:0> "Groups::AnnouncementPolicy".safe_constantize
=> Groups::AnnouncementPolicy I've also since restarted my machine and rebuilt the Docker container after electrical maintenance and... it seems to work now. We had been restarting the web server within the Docker image (docker-compose restart app) and there was no change. I'm not sure what's brought this about but it seems to be resolved 😕. Perhaps it was some issue with Rails auto-reloading. Sorry for this! |
Tell us about your environment
Ruby Version:
2.4.3
Framework Version (Rails, whatever):
Rails 5.2.0.rc2
Action Policy Version:
0.1.4
What did you do?
Called
authorize!
fromGroups::AnnouncementsController#show
(/app/controllers/groups/announcements_controller.rb
) with no arguments.What did you expect to happen?
For the policy
Groups::AnnouncementPolicy
(/app/policies/groups/announcement_policy.rb
) orGroup::AnnouncementPolicy
(/app/policies/group/announcement_policy.rb
) (tried both) to be found and to authorise#show
.What actually happened?
Moving the policy out of a directory and calling it
::AnnouncementPolicy
works just fine, but I'd rather keep the namespace :)For reference, the policy as-is:
The text was updated successfully, but these errors were encountered: