Files

Kaminari::PageScopeMethods

Public Instance Methods

current_page() click to toggle source

Current page number

# File lib/kaminari/models/page_scope_methods.rb, line 27
def current_page
  (offset_value / limit_value) + 1
end
first_page?() click to toggle source

First page of the collection ?

# File lib/kaminari/models/page_scope_methods.rb, line 32
def first_page?
  current_page == 1
end
last_page?() click to toggle source

Last page of the collection?

# File lib/kaminari/models/page_scope_methods.rb, line 37
def last_page?
  current_page >= total_pages
end
num_pages() click to toggle source

FIXME for compatibility. remove num_pages at some time in the future

Alias for: total_pages
padding(num) click to toggle source
# File lib/kaminari/models/page_scope_methods.rb, line 15
def padding(num)
  offset(offset_value + num.to_i)
end
per(num) click to toggle source

Specify the per_page value for the preceding page scope

Model.page(3).per(10)
# File lib/kaminari/models/page_scope_methods.rb, line 5
def per(num)
  if (n = num.to_i) <= 0
    self
  elsif max_per_page && max_per_page < n
    limit(max_per_page).offset(offset_value / limit_value * max_per_page)
  else
    limit(n).offset(offset_value / limit_value * n)
  end
end
total_pages() click to toggle source

Total number of pages

# File lib/kaminari/models/page_scope_methods.rb, line 20
def total_pages
  (total_count.to_f / limit_value).ceil
end
Also aliased as: num_pages

[Validate]

Generated with the Darkfish Rdoc Generator 2.