Skip to content

Commit

Permalink
fix for pagy_url_for not working with multiple pagy in the same request
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Mar 13, 2019
1 parent 75329b4 commit e9f467a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/pagy/frontend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e9f467a

Please sign in to comment.