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-3.4.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-3.3.0 lib/patches/debug_exceptions/patch-5-0.rb
inertiax_rails-2.0.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-3.2.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-3.1.4 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-3.1.3 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-3.1.2 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-3.1.1 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-3.1.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-3.0.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-2.0.1 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-2.0.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.12.1 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.12.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.11.1 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.11.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.10.0 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.9.2 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.9.1 lib/patches/debug_exceptions/patch-5-0.rb
inertia_rails-1.9.0 lib/patches/debug_exceptions/patch-5-0.rb