require 'will_paginate/collection' require 'will_paginate/per_page' # http://www.desimcadam.com/archives/8 Array.class_eval do def paginate(options = {}) raise ArgumentError, "parameter hash expected (got #{options.inspect})" unless Hash === options page = options[:page] || 1 per_page = options[:per_page] || WillPaginate.per_page total = options[:total_entries] || self.length WillPaginate::Collection.create(page, per_page, total) do |pager| pager.replace self[pager.offset, pager.per_page].to_a end end end