Module: Kaminari::Helpers::SinatraHelpers
- Defined in:
- lib/kaminari_patch.rb
Defined Under Namespace
Modules: HelperMethods Classes: ActionViewTemplateProxy
Instance Method Summary collapse
Instance Method Details
#page_entries_info(collection, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kaminari_patch.rb', line 14 def page_entries_info(collection, = {}) entry_name = if [:entry_name] [:entry_name] elsif collection.empty? || collection.is_a?(Array) 'entry' else if collection.respond_to? :model # DataMapper collection.model.model_name.human.downcase else # AR collection.model_name.human.downcase end end entry_name = entry_name.pluralize unless collection.total_count == 1 if collection.total_pages < 2 t('helpers.page_entries_info.one_page.display_entries', :entry_name => entry_name, :count => collection.total_count) else first = collection.offset_value + 1 last = collection.last_page? ? collection.total_count : collection.offset_value + collection.limit_value t('helpers.page_entries_info.more_pages.display_entries', :entry_name => entry_name, :first => first, :last => last, :total => collection.total_count) end.html_safe end |