Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
17 lines (14 sloc) 0.468 kB
require 'will_paginate/collection'
# http://www.desimcadam.com/archives/8
Array.class_eval do
def paginate(options = {})
raise ArgumentError, "parameter hash expected (got #{options.inspect})" unless Hash === options
WillPaginate::Collection.create(
options[:page] || 1,
options[:per_page] || 30,
options[:total_entries] || self.length
) { |pager|
pager.replace self[pager.offset, pager.per_page].to_a
}
end
end
Jump to Line
Something went wrong with that request. Please try again.