Behavior of view helper is incorrect if URL includes "@"
-
Mislav
- State changed from new to resolved
That is because of the internal "optimization" when generating URLs.
You can either use will_paginate 3.0 (not yet released, find it in the "agnostic" branch) or this monkeypatch:
WillPaginate::LinkRenderer.class_eval do protected def url_for(page) url_params = {} # page links should preserve GET parameters stringified_merge url_params, @template.params if @template.request.get? stringified_merge url_params, @options[:params] if @options[:params] if complex = param_name.index(/[^\w-]/) page_param = (defined?(CGIMethods) ? CGIMethods : ActionController::AbstractRequest). parse_query_parameters("#{param_name}=#{page}") stringified_merge url_params, page_param else url_params[param_name] = page end @template.url_for(url_params) end end -
Anton Ageev
The monkeypatch brokes all page links. I get "/blogs/@Andrex" instead of "/blogs/@Andres/pages/(\d+)" for any page.
-
Mislav
Ouch. Then how about
WillPaginate::LinkRenderer.class_eval do protected def url_for(page) url_params = {} # page links should preserve GET parameters stringified_merge url_params, @template.params if @template.request.get? stringified_merge url_params, @options[:params] if @options[:params] url_params[param_name.to_sym] = page @template.url_for(url_params) end end -
Anton Ageev
Thanks. It works fine.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.