Module: InertiaRails::InertiaDebugExceptions

Defined in:
lib/patches/debug_exceptions.rb

Instance Method Summary collapse

Instance Method Details

#render_for_browser_request(request, wrapper) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/patches/debug_exceptions.rb', line 15

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