Open ryanwood opened 6 years ago
@ryanwood went down this same route but this is not an area i want to be monkey patching, what did you end up doing?
I'm just trying to add missing context back into logs
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
def append_info_to_payload(payload)
super
payload[:service] = :stripe
# ...truncated
end
end
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.