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
I have a situation where I need to handle a particular email API error across all webhook processing.
I attempted to rescue_from to my ApplicationController but my specs weren't showing that the error was handled. I then realized that StripeEvent::WebhooksController extends ActionController::Base rather than ApplicationController. I realize that ApplicationController is a Rails 5.0+ feature whereas using ActionController::Base works for everyone.
These are the options I could think of to accomplish my goal:
Have StripeEvent::WebhooksController extend ApplicationController (patch the gem)
I tried to create my own WebhooksController which extended StripeEvent::WebhooksController. Then I updated the routes to just point to webhooks#event but I ended up with a RuntimeError: Circular dependency detected while autoloading constant WebhooksController error. :(
The last option I'm aware of is to copy the StripeEvent::WebhooksController into a controller that I manage. That sounds horrible as I'd have to manually keep that controller in sync.
Ideally, if you didn't want to change to use ApplicationController you could take an approach similar to Devise and allow the setting of the parent controller via the config.
class DeviseController < Devise.parent_controller.constantize
I have a situation where I need to handle a particular email API error across all webhook processing.
I attempted to
rescue_from
to myApplicationController
but my specs weren't showing that the error was handled. I then realized thatStripeEvent::WebhooksController
extendsActionController::Base
rather thanApplicationController
. I realize thatApplicationController
is a Rails 5.0+ feature whereas usingActionController::Base
works for everyone.These are the options I could think of to accomplish my goal:
StripeEvent::WebhooksController
extendApplicationController
(patch the gem)WebhooksController
which extendedStripeEvent::WebhooksController
. Then I updated the routes to just point towebhooks#event
but I ended up with aRuntimeError: Circular dependency detected while autoloading constant WebhooksController
error. :(StripeEvent::WebhooksController
into a controller that I manage. That sounds horrible as I'd have to manually keep that controller in sync.Ideally, if you didn't want to change to use
ApplicationController
you could take an approach similar to Devise and allow the setting of the parent controller via the config.class DeviseController < Devise.parent_controller.constantize
https://github.com/plataformatec/devise/blob/be15116426ef8f43ee07686bcacdbe41a213e7fe/app/controllers/devise_controller.rb#L4
https://github.com/plataformatec/devise/blob/962cea2039c72a92691af734ebbd8495dd5c0501/lib/devise.rb#L230-L234
I'm certainly open if there is another simpler way to accomplish this. Thanks.
The text was updated successfully, but these errors were encountered: