Sha256: 935838e679bb70c2d23e60a8be013420eb1f857c51816abe6eb436803bad9539
Contents?: true
Size: 802 Bytes
Versions: 4
Compression:
Stored size: 802 Bytes
Contents
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
4 entries across 4 versions & 1 rubygems