Module: Pagy::Helpers

Included in:
Backend, Frontend
Defined in:
lib/pagy/frontend.rb

Instance Method Summary collapse

Instance Method Details

#pagy_get_params(params) ⇒ Object

Sub-method called only by #pagy_url_for: here for easy customization of params by overriding



24
# File 'lib/pagy/frontend.rb', line 24

def pagy_get_params(params) = params

#pagy_url_for(page, pagy, url = nil) ⇒ Object

This works with all Rack-based frameworks (Sinatra, Padrino, Rails, …)



16
17
18
19
20
21
# File 'lib/pagy/frontend.rb', line 16

def pagy_url_for(page, pagy, url=nil)
  p_vars = pagy.vars
  params = request.GET.merge(p_vars[:params])
  params[p_vars[:page_param].to_s] = page
  "#{request.base_url if url}#{request.path}?#{Rack::Utils.build_nested_query(pagy_get_params(params))}#{p_vars[:anchor]}"
end