varvet / pundit

Minimal authorization through OO design and pure Ruby classes
MIT License
8.21k stars 624 forks source link

Prevent usage of `only:` filter for limiting `after_action` filter #788

Closed a-nickol closed 1 month ago

a-nickol commented 8 months ago

Starting with Rails 7.1 a new security check has been added; it checks whether referenced actions do exist for a given filter. (https://guides.rubyonrails.org/configuring.html#config-action-controller-raise-on-missing-callback-actions)

Because we cannot guaranty that all controller have a index method, the given example in the readme of Pundit for a after_action checking the usage of the lib will raise exceptions in a default rails application.

This Pull requests changes the code example to use just a normal if statement to check the given action_name.