Module: ControllerUtils

Included in:
DocsController, SearchController
Defined in:
app/helpers/controller_utils.rb

Instance Method Summary collapse

Instance Method Details

#get_total_docsObject

Count the number of docs across all models


11
12
13
14
15
# File 'app/helpers/controller_utils.rb', line 11

def get_total_docs
  return @models.inject(0) do |total_count, m|
    total_count += m.count
  end
end

#page_calc(params) ⇒ Object

Calculate start and page num


3
4
5
6
7
8
# File 'app/helpers/controller_utils.rb', line 3

def page_calc(params)    
  pagenum = params[:page] ? params[:page].to_i : 1
  start = pagenum*30-30

  return pagenum, start
end