Module: NdrError::ApplicationHelper

Defined in:
app/helpers/ndr_error/application_helper.rb

Overview

Application-wide helpers. TODO: await ndr_ui gem!

Instance Method Summary collapse

Instance Method Details

#pagination_summary_for(collection) ⇒ Object

Pagination helper for will_paginate:



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/ndr_error/application_helper.rb', line 6

def pagination_summary_for(collection)
  page    = collection.current_page
  showing = collection.per_page
  total   = collection.total_entries

  from = (page - 1) * showing + 1
  to   = from + collection.length - 1

  from = [from, total].min
  to   = [to, total].min

  format('Showing %d - %d of %d', from, to, total)
end