Module: InertiaRails::InertiaDebugExceptions

Defined in:
lib/patches/debug_exceptions/patch-5-0.rb,
lib/patches/debug_exceptions/patch-5-1.rb

Instance Method Summary collapse

Instance Method Details

#render_for_browser_request(request, wrapper) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/patches/debug_exceptions/patch-5-1.rb', line 11

def render_for_browser_request(request, wrapper)
  template = create_template(request, wrapper)
  file = "rescues/#{wrapper.rescue_template}"

  if request.xhr? && !request.headers['X-Inertia'] # <<<< this line is changed only
    body = template.render(template: file, layout: false, formats: [:text])
    format = "text/plain"
  else
    body = template.render(template: file, layout: "rescues/layout")
    format = "text/html"
  end

  render(wrapper.status_code, body, format)
end

#render_for_default_application(request, wrapper) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/patches/debug_exceptions/patch-5-0.rb', line 9

def render_for_default_application(request, wrapper)
  template = create_template(request, wrapper)
  file = "rescues/#{wrapper.rescue_template}"

  if request.xhr? && !request.headers['X-Inertia'] # <<<< this line is changed only
    body = template.render(template: file, layout: false, formats: [:text])
    format = "text/plain"
  else
    body = template.render(template: file, layout: 'rescues/layout')
    format = "text/html"
  end
  render(wrapper.status_code, body, format)
end