Skip to content

Commit

Permalink
Use lazy load hooks to hook on ActionController::Base:
Browse files Browse the repository at this point in the history
- Calling directly ActionController::Base affects the initialization process (one of them being one that controls ActionController configuration)
- As a result setting configuration inside an initializer (such as the asset_host), doesn't have any effect
  • Loading branch information
Edouard-chin committed Nov 14, 2017
1 parent 3fed75f commit 0448d02
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/bugsnag/integrations/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,14 @@ class Railtie < Rails::Railtie
config.middleware.insert_before Bugsnag::Middleware::Callbacks, Bugsnag::Middleware::Rails3Request
end

if defined?(::ActionController::Base)
ActiveSupport.on_load(:action_controller) do
require "bugsnag/integrations/rails/controller_methods"
::ActionController::Base.send(:include, Bugsnag::Rails::ControllerMethods)
include Bugsnag::Rails::ControllerMethods
end
if defined?(ActionController::API)
require "bugsnag/integrations/rails/controller_methods"
ActionController::API.send(:include, Bugsnag::Rails::ControllerMethods)
end
if defined?(ActiveRecord::Base)

ActiveSupport.on_load(:active_record) do
require "bugsnag/integrations/rails/active_record_rescue"
ActiveRecord::Base.send(:include, Bugsnag::Rails::ActiveRecordRescue)
include Bugsnag::Rails::ActiveRecordRescue
end

Bugsnag.configuration.app_type = "rails"
Expand Down

0 comments on commit 0448d02

Please sign in to comment.