lib/airbrake/railtie.rb in airbrake-3.1.6 vs lib/airbrake/railtie.rb in airbrake-3.1.7

- old
+ new

@@ -1,18 +1,20 @@ require 'airbrake' require 'rails' +require 'airbrake/rails/middleware' + module Airbrake class Railtie < ::Rails::Railtie rake_tasks do require 'airbrake/rake_handler' - require "airbrake/rails3_tasks" + require 'airbrake/rails3_tasks' end - initializer "airbrake.use_rack_middleware" do |app| + initializer "airbrake.middleware" do |app| + app.config.middleware.use "Airbrake::Rails::Middleware" app.config.middleware.insert 0, "Airbrake::UserInformer" - app.config.middleware.insert_after "Airbrake::UserInformer","Airbrake::Rack" end config.after_initialize do Airbrake.configure(true) do |config| config.logger ||= config.async? ? ::Logger.new(STDERR) : ::Rails.logger @@ -22,27 +24,18 @@ end ActiveSupport.on_load(:action_controller) do # Lazily load action_controller methods # - require 'airbrake/rails/javascript_notifier' require 'airbrake/rails/controller_methods' - include Airbrake::Rails::JavascriptNotifier include Airbrake::Rails::ControllerMethods end - if defined?(::ActionDispatch::DebugExceptions) - # We should catch the exceptions in ActionDispatch::DebugExceptions in Rails 3.2.x. - # - require 'airbrake/rails/middleware/exceptions_catcher' - ::ActionDispatch::DebugExceptions.send(:include,Airbrake::Rails::Middleware::ExceptionsCatcher) - elsif defined?(::ActionDispatch::ShowExceptions) - # ActionDispatch::DebugExceptions is not defined in Rails 3.0.x and 3.1.x so - # catch the exceptions in ShowExceptions. - # - require 'airbrake/rails/middleware/exceptions_catcher' - ::ActionDispatch::ShowExceptions.send(:include,Airbrake::Rails::Middleware::ExceptionsCatcher) + if defined?(::ActionController::Base) + require 'airbrake/rails/javascript_notifier' + + ::ActionController::Base.send(:include, Airbrake::Rails::JavascriptNotifier) end end end end