Best way to find out if a Pundit policy is used anywhere?

45 Views Asked by At

We're currently cleaning up our policies, removing deprecated ones. Many of our models have policies with the same name, for example view? or update?.

Sometimes we just want to know if the user has permission to do a type of thing on a model. These will be straightforward to search for in the code base:

authorize Group, :view_all?

More often, we want to check whether the user can do something on a specific record:

group = Group.find(@group_id)
authorize group, :view?

I'm looking for advice on the latter case. For our longer model names, there are several different abbreviated forms we might use when retrieving an instance, not to mention any naming we do in context (e.g. group_to_delete), so the variable name isn't a given.

0

There are 0 best solutions below