Module: Debugbar::TagHelpers

Defined in:
app/helpers/debugbar/tag_helpers.rb

Instance Method Summary collapse

Instance Method Details

#debugbar_body(opt = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/debugbar/tag_helpers.rb', line 10

def debugbar_body(opt = {})
  opt = ActiveSupport::HashWithIndifferentAccess.new(opt)

  # See https://github.com/julienbourdeau/debugbar/issues/8
  if !defined?(ActionCable) && opt[:mode].nil?
    opt[:mode] = 'poll'
  end

  if opt[:active_record].nil?
    opt[:active_record] = { adapter: db_adapter }
  end

  html = <<-HTML
    <div id="__debugbar" data-turbo-permanent></div>
  HTML

  html += <<-HTML
    <script type="text/javascript" data-turbo-permanent nonce="#{opt.delete(:nonce)}">
      window._debugbarConfigOptions = #{opt.to_json}
    </script>
  HTML

  Debugbar.config.enabled? ? raw(html) : ""
end

#debugbar_headObject



2
3
4
5
6
7
8
# File 'app/helpers/debugbar/tag_helpers.rb', line 2

def debugbar_head
  html = <<-HTML
    <script defer src="#{Debugbar.config.prefix}/assets/script"></script>
  HTML

  Debugbar.config.enabled? ? raw(html) : ""
end

#debugbar_javascript(opt = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'app/helpers/debugbar/tag_helpers.rb', line 35

def debugbar_javascript(opt = {})
  errors = [""]
  errors << "debugbar_javascript was removed in 0.3.0."
  errors << "Please use `debugbar_head` inside <head> and `debugbar_body` at the end of <body> instead."
  errors << "It was split to support Turbo Drive."
  errors << "See https://debugbar.dev/changelog/ for more information."
  errors << ""
  raise errors.join("\n")
end