Module: Turbolinks::LegacyXHRRedirect

Defined in:
lib/turbolinks/xhr_redirect.rb

Overview

TODO: Remove me when support for Ruby < 2 && Rails < 4 is dropped

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



16
17
18
# File 'lib/turbolinks/xhr_redirect.rb', line 16

def self.included(base)
  base.alias_method_chain :call, :turbolinks
end

Instance Method Details



20
21
22
23
24
25
26
27
28
# File 'lib/turbolinks/xhr_redirect.rb', line 20

def call_with_turbolinks(env)
  status, headers, body = call_without_turbolinks(env)

  if env['rack.session'] && env['HTTP_X_XHR_REFERER']
    env['rack.session'][:_turbolinks_redirect_to] = headers['Location']
  end

  [status, headers, body]
end