You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the policy name is inferred from the controller class for authorize! and allowed_to? like so:
controller_name.classify.safe_constantize
There's no way to override this globally (per controller run) currently. Would you be open to adding this as a feature?
My use case is that I have a controller that is re-used in several contexts in the site. It is aware of its context, and depending on the context a different policy should be used. I can supply the context to authorise! easy enough with the :with option, but it's much harder to do so with the view helper allowed_to? because sometimes this method is called with helpers shared across wide areas of the application and rely on the inferred controller to function cleanly.
I thought about passing the context into the controllers inferred policy, then splitting out the policy check from there but didn't get too far.
The text was updated successfully, but these errors were encountered:
Currently the policy name is inferred from the controller class for
authorize!
andallowed_to?
like so:controller_name.classify.safe_constantize
There's no way to override this globally (per controller run) currently. Would you be open to adding this as a feature?
My use case is that I have a controller that is re-used in several contexts in the site. It is aware of its context, and depending on the context a different policy should be used. I can supply the context to
authorise!
easy enough with the:with
option, but it's much harder to do so with the view helperallowed_to?
because sometimes this method is called with helpers shared across wide areas of the application and rely on the inferred controller to function cleanly.I thought about passing the context into the controllers inferred policy, then splitting out the policy check from there but didn't get too far.
The text was updated successfully, but these errors were encountered: