Replies: 1 comment 1 reply
-
|
I maintain a modest codebase with over 100 policies. I typically do per-model policies. I use a plural namespace for nested resources, which typically line up with nested resource controllers. Sometimes policies are per-controller, and I use a similar naming convention, and explicitly use Lastly, personally, I'm not a fan of the singular namespaces, because it ends up nesting the policy under the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When I started using
action_policy, I thought that "1 policy per controller" was the best way to organize my policies, eg:PostsController=>PostPolicyAdmin::PostsController=>Admin::PostPolicyPostReportsController=>API::PostPolicyAdmin::FeaturedPostsController=>Admin::FeaturedPostPolicyIt is working for my projects, I'm working on other projects that use "1 policy per model/resource" and reuse the policy on multiple controllers, eg.:
I don't have any objections with the second approach, but I have the feeling it will become harder to maintain, while I know the first approach can be easier to have duplicated/outdated permission code without a proper.
How do you organize your policies and has it worked well??
Beta Was this translation helpful? Give feedback.
All reactions