Class: Rango::Pagination::Strategies::PageNumberOnTheEndOfRouteExcludeFirstPage

Inherits:
Rango::Pagination::Strategy show all
Defined in:
lib/rango/contrib/pagination/strategies.rb

Instance Method Summary collapse

Methods inherited from Rango::Pagination::Strategy

activate

Instance Method Details

#hook(request, from, page) ⇒ Object

Here is terrible important the from parameter

Since:

  • 0.0.2



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rango/contrib/pagination/strategies.rb', line 35

def hook(request, from, page)
  if from.number.eql?(1)
    # /products
    File.join(request.url, page.to_s)
  elsif page.eql?(1) && ! from.number.eql?(1)
    File.join((request.url)[0..-2]).chomp("/")
  else
    # /products/2
    return PageNumberOnTheEndOfRoute.new.hook(request, from, page)
  end
end