Skip to content

Instantly share code, notes, and snippets.

@schovi
Created February 10, 2011 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schovi/821099 to your computer and use it in GitHub Desktop.
Save schovi/821099 to your computer and use it in GitHub Desktop.
Quick WillPaginate fix, after that will_paginate method will accept param :url => my_route_path
class WillPaginate::ViewHelpers::LinkRenderer
def url(page)
@base_url_params ||= begin
url_params = base_url_params
merge_optional_params(url_params)
url_params
end
url_params = @base_url_params.dup
add_current_page_param(url_params, page)
@options[:url] ? merge_parameters_with_string_url(@options[:url], url_params) : @template.url_for(url_params)
end
def merge_parameters_with_string_url(url, url_params)
url_params = url_params.except(:escape, :controller, :action)
string_attributes = url_params.collect do |key, val|
"#{key}=#{CGI::escapeHTML(val.to_s)}"
end
url + "?#{string_attributes.join("&")}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment