Closed eoinkelly closed 9 months ago
I'd prefer option one, at least for now while we see what approaches others take. Filters, particularly at the ApplicationController level, ideally shouldn't be making such assumptions about the shape a particular controller takes. I can see the value, but it feels like coding around it is worse.
We have decided on option one.
Rails 7.1 enables a feature where it will raise exception if your controller callback references an action which doesn't exist. Unfortunately this check seems to be performed before the
if:
/unless:
option of the callback is evaluated. More details on the feature:Our generated
ApplicationController
includes the following:These
after_action
raise exceptions if they are run in a controller which does not have anindex
action. For example, the deviseSessionsController
andRegistionsController
e.g.These
after_action
s will also fail on any controller we define in future that doesn't have anindex
.What are our options for handling this?
Option 1: Just disable config.action_controller.raise_on_missing_callback_actions
Pros/Cons (++/--)
Option 2: Move the controller action name check into the
if:
/unless:
optionsI tried this locally and it does work.
Pros/Cons (++/--)
-- The code is less obvious and more clever now. We can mitigate this a bit by trying to choose a good name for the
if:
/unless:
method but it's still more surprising/clever than what we currently have.Option 3: Remove the pundit policy checks
I'm rejecting this option immediately because losing policy checks is a much worse outcome than missing out on a new safety check from Rails.