Sha256: 8e00dc9cb8a112875ac71ff0d57c7de5cd2a6f09855c15fd3ae532d6fc751a6d

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

# Rails 3.x hooks

require "rails"
require "bugsnag"
require "bugsnag/middleware/rails3_request"
require "bugsnag/middleware/rack_request"

module Bugsnag
  class Railtie < Rails::Railtie
    rake_tasks do
      load "bugsnag/tasks/bugsnag.rake"
    end

    config.before_initialize do
      # Configure bugsnag rails defaults
      Bugsnag.configure do |config|
        config.logger = Rails.logger
        config.release_stage = Rails.env.to_s
        config.project_root = Rails.root.to_s
        config.params_filters += Rails.configuration.filter_parameters
        config.middleware.insert_before Bugsnag::Middleware::Callbacks, Bugsnag::Middleware::Rails3Request
      end

      # Auto-load configuration settings from config/bugsnag.yml if it exists
      config_file = Rails.root.join("config", "bugsnag.yml")
      config = YAML.load_file(config_file) if File.exists?(config_file)
      Bugsnag.configure(config[Rails.env] ? config[Rails.env] : config) if config

      if defined?(::ActionController::Base)
        require "bugsnag/rails/controller_methods"
        ::ActionController::Base.send(:include, Bugsnag::Rails::ControllerMethods)
      end
    end

    initializer "bugsnag.use_rack_middleware" do |app|
      begin
        app.config.middleware.insert_after ActionDispatch::DebugExceptions, "Bugsnag::Rack"
      rescue
        app.config.middleware.use "Bugsnag::Rack"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bugsnag-1.5.3 lib/bugsnag/railtie.rb
bugsnag-1.5.2 lib/bugsnag/railtie.rb
bugsnag-1.5.1 lib/bugsnag/railtie.rb
bugsnag-1.5.0 lib/bugsnag/railtie.rb
bugsnag-1.4.2 lib/bugsnag/railtie.rb
bugsnag-1.4.1 lib/bugsnag/railtie.rb
bugsnag-1.4.0 lib/bugsnag/railtie.rb