Sha256: 8dee866afdb75e8d5fae2b9fdbb11cb98063989cd8934eb35572eadc4f67a211
Contents?: true
Size: 900 Bytes
Versions: 1
Compression:
Stored size: 900 Bytes
Contents
# WillPaginateSearch # Copyright (c) 2007 - 2011 Douglas F Shearer. # http://douglasfshearer.com module ActsAsIndexed module WillPaginate module Search def paginate_search(query, options) page = options.fetch(:page) { raise ArgumentError, ":page parameter required" } per_page = options.delete(:per_page) || self.per_page total_entries = options.delete(:total_entries) total_entries ||= find_with_index(query,{},{:ids_only => true}).size pager = ::WillPaginate::Collection.new(page, per_page, total_entries) options.update :offset => pager.offset, :limit => pager.per_page options = options.delete_if {|key, value| [:page, :per_page].include?(key) } pager.replace find_with_index(query, options) pager end end end end class ActiveRecord::Base extend ActsAsIndexed::WillPaginate::Search end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts_as_indexed-0.7.8 | lib/will_paginate_search.rb |