Sha256: be5c3c826ae64f4754873139f666b8f774e99e4d69d75dcc0b541c5dd91727d0

Contents?: true

Size: 853 Bytes

Versions: 30

Compression:

Stored size: 853 Bytes

Contents

# Patch ActionDispatch::DebugExceptions to render HTML for Inertia requests
#
# Original source:
# https://github.com/rails/rails/blob/5-0-stable/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
#

ActionDispatch::DebugExceptions.class_eval do
  prepend(InertiaDebugExceptions = Module.new do
    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
  end)
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
inertia_rails-1.8.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.7.1 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.7.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.6.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.5.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.4.1 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.4.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.3.1 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.3.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.2.2 lib/patches/debug_exceptions/patch-5-0.rb