-
Notifications
You must be signed in to change notification settings - Fork 386
Expand file tree
/
Copy pathrailtie.rb
More file actions
52 lines (41 loc) · 1.4 KB
/
railtie.rb
File metadata and controls
52 lines (41 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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'
end
initializer "airbrake.middleware" do |app|
middleware = if defined?(ActionDispatch::DebugExceptions)
# Rails >= 3.2.0
"ActionDispatch::DebugExceptions"
else
# Rails < 3.2.0
"ActionDispatch::ShowExceptions"
end
app.config.middleware.insert_after middleware,
"Airbrake::Rails::Middleware"
app.config.middleware.insert 0, "Airbrake::UserInformer"
end
config.after_initialize do
Airbrake.configure(true) do |config|
config.logger ||= config.async? ? ::Logger.new(STDERR) : ::Rails.logger
config.environment_name ||= ::Rails.env
config.project_root ||= ::Rails.root
config.framework = "Rails: #{::Rails::VERSION::STRING}"
end
ActiveSupport.on_load(:action_controller) do
# Lazily load action_controller methods
#
require 'airbrake/rails/controller_methods'
include Airbrake::Rails::ControllerMethods
end
if defined?(::ActionController::Base)
require 'airbrake/rails/javascript_notifier'
::ActionController::Base.send(:include, Airbrake::Rails::JavascriptNotifier)
end
end
end
end