Closed drewmoore closed 2 years ago
Just came here to raise the same thing.
There's also a good blog post from The Pug Automatic going into this in some detail.
@drewmoore could you expand on what you mean by "instead just use the exact same pattern as for our ActiveRecord models' policies."?
@drewmoore We've discussed this and concluded that there isn't a particular reason to use Struct. We'd happily accept a PR which changes the documentation to a different approach if you have something specific in mind.
@drewmoore could you expand on what you mean by "instead just use the exact same pattern as for our ActiveRecord models' policies."?
Oh yes, I just meant that we are able to declare our headless policies in exactly the same manner as any other type of policy. I provided a documentation update on #717.
Closed by #171
Thanks for this great gem! When trying to implement a headless policy, rubocop advised against this. When experimenting on my own machine, I actually found it possible to avoid the usage of
Struct
altogether and instead just use the exact same pattern as for our ActiveRecord models' policies. This also works for me in views usingif policy(:my_resource).show?
. I'm wondering if Struct is needed, and if not, if the documentation could be updated to reflect this. Thanks!Ruby version: 2.7.3 Pundit version: 2.1.1