From 32b114577c388e0832fc8215eeef63a954c70705 Mon Sep 17 00:00:00 2001 From: Alexander Nickol Date: Thu, 19 Oct 2023 16:49:48 +0200 Subject: [PATCH] Update README.md The usage of an `only:` filter works because of Rails new policy `config.action_controller.raise_on_missing_callback_actions = true` not very well. --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 36d74d13..4a429a6d 100644 --- a/README.md +++ b/README.md @@ -362,8 +362,15 @@ authorize individual instances. ``` ruby class ApplicationController < ActionController::Base include Pundit::Authorization - after_action :verify_authorized, except: :index - after_action :verify_policy_scoped, only: :index + after_action :verify_pundit_authorization + + def verify_pundit_authorization + if action_name == "index" + verify_policy_scoped + else + verify_authorized + end + end end ```