Skip to content

Commit 449fc49

Browse files
Automatically set action_cable.disable_request_forgery_protection to true when loading the debugbar gem
There are issue where the extension or the debugbar aren't allowed by the actioncable backend.
1 parent c6f024b commit 449fc49

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

lib/debugbar/engine.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,22 @@ module Debugbar
77
class Engine < ::Rails::Engine
88
isolate_namespace Debugbar
99

10+
def log(msg)
11+
@logger ||= Logger.new(STDOUT)
12+
Array.wrap(msg).each { |m| @logger.warn(m) }
13+
end
14+
1015
initializer 'debugbar.config' do |app|
1116
app.config.debugbar = ::Debugbar.config
1217
end
1318

19+
initializer 'debugbar.override_config' do |app|
20+
unless app.config.action_cable.disable_request_forgery_protection
21+
app.config.action_cable.disable_request_forgery_protection = true
22+
log "Debugbar: Action Cable request forgery protection is enabled. This can cause issues with Debugbar. Overriding setting config.action_cable.disable_request_forgery_protection = true now. Update your configuration to get rid of this message."
23+
end
24+
end
25+
1426
initializer 'debugbar.init' do |app|
1527
# Display error message if running in multi-process mode without proper configuration
1628
if ENV["WEB_CONCURRENCY"].to_i > 1
@@ -30,8 +42,7 @@ class Engine < ::Rails::Engine
3042
"############################################################################################################",
3143
]
3244

33-
logger = Logger.new(STDOUT)
34-
msg.each { |m| logger.warn(m) }
45+
log msg
3546
end
3647
end
3748

0 commit comments

Comments
 (0)