class DataTables::Modules::Pagination
Constants
- DEFAULT_LENGTH
- FIRST_PAGE
Attributes
context[R]
scope[R]
Public Class Methods
new(model, scope, params)
click to toggle source
# File lib/data_tables/modules/pagination.rb, line 11 def initialize(model, scope, params) @scope = scope.dup @model = model @params = params end
Public Instance Methods
paginate()
click to toggle source
# File lib/data_tables/modules/pagination.rb, line 17 def paginate start = (@params[:start] || FIRST_PAGE).to_i length = (@params[:length] || DEFAULT_LENGTH).to_i page = (start / length) @scope.offset(page * length).limit(length) end