Permalink
Browse files

Strip _pjax param

  • Loading branch information...
josh committed Feb 22, 2012
1 parent 77c2480 commit e79a1cf58a8935eb132f4910f300cf86d081ae6d
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/pjax.rb
View
@@ -4,6 +4,7 @@ module Pjax
included do
layout proc { |c| pjax_request? ? pjax_layout : 'application' }
helper_method :pjax_request?
+ before_filter :strip_pjax_param
around_filter :set_pjax_url
end
@@ -16,6 +17,15 @@ def pjax_layout
false
end
+ def strip_pjax_param
+ params.delete(:_pjax)
+ request.env['QUERY_STRING'] = Rack::Utils.build_query(params)
+
+ request.env.delete('rack.request.query_string')
+ request.env.delete('rack.request.query_hash')
+ request.env.delete('action_dispatch.request.query_parameters')
+ end
+
def set_pjax_url
yield
response.headers['X-PJAX-URL'] = request.url

0 comments on commit e79a1cf

Please sign in to comment.