Module: Pagy::StandaloneExtra

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

Defined Under Namespace

Modules: QueryUtils

Instance Method Summary collapse

Instance Method Details

#pagy_url_for(pagy, page, absolute: nil) ⇒ Object

Return the URL for the page. If there is no pagy.vars it works exactly as the regular #pagy_url_for, relying on the params method and Rack. If there is a defined pagy.vars variable it does not need the params method nor Rack.



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/pagy/extras/standalone.rb', line 36

def pagy_url_for(pagy, page, absolute: nil)
  vars = pagy.vars
  return super unless (url = vars[:url])

  params                     = vars[:params]
  params[vars[:page_param]]  = page
  params[vars[:items_param]] = vars[:items] if vars[:items_extra]

  query_string = "?#{QueryUtils.build_nested_query(pagy_massage_params(params))}"
  "#{url}#{query_string}#{vars[:fragment]}"
end