Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 13, 2024

Conversation

a-nickol
Copy link
Contributor

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.

The usage of an `only:` filter works because of Rails new policy   `config.action_controller.raise_on_missing_callback_actions = true` not very well.
@a-nickol a-nickol changed the title Prevent usage of only: filter for controller filter Prevent usage of only: filter for limit after_action filter Oct 19, 2023
@a-nickol a-nickol changed the title Prevent usage of only: filter for limit after_action filter Prevent usage of only: filter for limiting after_action filter Oct 19, 2023
Copy link
Member

@Burgestrand Burgestrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I think this is a good idea. Documentation examples should run well with default settings.

@Burgestrand Burgestrand merged commit f55c442 into varvet:main May 13, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants