Method: Kaminari::PageScopeMethods#total_pages

Defined in:
lib/kaminari/models/page_scope_methods.rb

#total_pagesObject

Total number of pages



35
36
37
38
39
40
41
42
43
44
# File 'lib/kaminari/models/page_scope_methods.rb', line 35

def total_pages
  count_without_padding = total_count
  count_without_padding -= @_padding if defined?(@_padding) && @_padding
  count_without_padding = 0 if count_without_padding < 0

  total_pages_count = (count_without_padding.to_f / limit_value).ceil
  max_pages && (max_pages < total_pages_count) ? max_pages : total_pages_count
rescue FloatDomainError
  raise ZeroPerPageOperation, "The number of total pages was incalculable. Perhaps you called .per(0)?"
end