Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rails 2.3 compat: query parameter parsing with Rack

  • Loading branch information...
commit e0b094f44cf39e704f9862c708b202d331604cf7 1 parent 23e37cc
@kamal kamal authored committed
Showing with 19 additions and 3 deletions.
  1. +19 −3 lib/will_paginate/view_helpers/action_view.rb
View
22 lib/will_paginate/view_helpers/action_view.rb
@@ -129,9 +129,7 @@ def add_current_page_param(url_params, page)
unless param_name.index(/[^\w-]/)
url_params[param_name.to_sym] = page
else
- page_param = (defined?(CGIMethods) ? CGIMethods : ActionController::AbstractRequest).
- parse_query_parameters(param_name + '=' + page.to_s)
-
+ page_param = parse_query_parameters("#{param_name}=#{page}")
symbolized_update(url_params, page_param)
end
end
@@ -139,4 +137,22 @@ def add_current_page_param(url_params, page)
def get_request?
@template.request.get?
end
+
+ private
+
+ def parse_query_parameters(params)
+ if defined? Rack::Utils
+ # For Rails > 2.3
+ Rack::Utils.parse_nested_query(params)
+ elsif defined?(ActionController::AbstractRequest)
+ ActionController::AbstractRequest.parse_query_parameters(params)
+ elsif defined?(ActionController::UrlEncodedPairParser)
+ # For Rails > 2.2
+ ActionController::UrlEncodedPairParser.parse_query_parameters(params)
+ elsif defined?(CGIMethods)
+ CGIMethods.parse_query_parameters(params)
+ else
+ raise "unsupported ActionPack version"
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.