Module: AppFrame::ControllerMethods::PaginationSupport

Extended by:
ActiveSupport::Concern
Defined in:
lib/app_frame/controller_methods.rb

Instance Method Summary collapse

Instance Method Details

#collectionObject

paginate collection



104
105
106
# File 'lib/app_frame/controller_methods.rb', line 104

def collection
  get_collection_ivar || set_collection_ivar(end_of_association_chain ? end_of_association_chain.page(page).per(per_page) : nil)
end

#countObject



116
117
118
119
120
121
122
# File 'lib/app_frame/controller_methods.rb', line 116

def count
  @count ||= if end_of_association_chain
    end_of_association_chain.count 
  else
    0
  end
end

#pageObject



108
109
110
# File 'lib/app_frame/controller_methods.rb', line 108

def page
  (params[:page] || 1).to_i
end

#per_pageObject



112
113
114
# File 'lib/app_frame/controller_methods.rb', line 112

def per_page
  20
end