From e9f467a49233a1c31233108a536e9a8a61cc1917 Mon Sep 17 00:00:00 2001 From: Domizio Demichelis Date: Wed, 13 Mar 2019 19:05:38 +0700 Subject: [PATCH] fix for pagy_url_for not working with multiple pagy in the same request --- lib/pagy/frontend.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pagy/frontend.rb b/lib/pagy/frontend.rb index 44f23d327..8f855e253 100644 --- a/lib/pagy/frontend.rb +++ b/lib/pagy/frontend.rb @@ -13,10 +13,12 @@ class Pagy module Helpers # This works with all Rack-based frameworks (Sinatra, Padrino, Rails, ...) def pagy_url_for(page, pagy, path_or_url=:path) - p_vars = pagy.vars; params = request.GET; params[p_vars[:page_param].to_s] = page; params.merge!(p_vars[:params]) + p_vars = pagy.vars; params = request.GET.merge(p_vars[:params]); params[p_vars[:page_param].to_s] = page "#{request.send(path_or_url)}?#{Rack::Utils.build_nested_query(pagy_get_params(params))}#{p_vars[:anchor]}" end + + # Sub-method called only by #pagy_url_for: here for easy customization of params by overriding def pagy_get_params(params) params end end