module Pjax

Protected Instance Methods

pjax_container() click to toggle source
# File lib/pjax.rb, line 32
def pjax_container
  return unless pjax_request?
  request.headers['X-PJAX-Container']
end
pjax_layout() click to toggle source
# File lib/pjax.rb, line 28
def pjax_layout
  false
end
pjax_request?() click to toggle source
# File lib/pjax.rb, line 24
def pjax_request?
  request.env['HTTP_X_PJAX'].present?
end
pjax_unsupported() click to toggle source
# File lib/pjax.rb, line 37
def pjax_unsupported
  head :not_acceptable
end
prevent_pjax!() click to toggle source

Call in a before_action or in an action to disable pjax on an action.

Examples

before_action :prevent_pjax!

def login
  prevent_pjax!
  # ...
end
# File lib/pjax.rb, line 52
def prevent_pjax!
  raise Pjax::Unsupported if pjax_request?
end
set_pjax_url() click to toggle source
# File lib/pjax.rb, line 68
def set_pjax_url
  response.headers['X-PJAX-URL'] = request.url
end
strip_pjax_param() click to toggle source
# File lib/pjax.rb, line 56
def strip_pjax_param
  params.delete(:_pjax)
  request.env['QUERY_STRING'] = request.env['QUERY_STRING'].sub(/\A_pjax=[^&]+&?|&_pjax=[^&]+/, '')

  request.env.delete('rack.request.query_string')
  request.env.delete('rack.request.query_hash')
  request.env.delete('action_dispatch.request.query_parameters')

  request.instance_variable_set('@original_fullpath', nil)
  request.instance_variable_set('@fullpath', nil)
end