Permalink
Browse files

fix up will_paginate support

  • Loading branch information...
1 parent 85a0200 commit caac05e4108d35fc0a419e0238def04bdb414acf novalis committed Feb 12, 2012
Showing with 8 additions and 6 deletions.
  1. +8 −6 lib/will_paginate_search.rb
@@ -9,17 +9,19 @@ module WillPaginate
module Search
def paginate_search(query, options)
- page, per_page, total_entries = wp_parse_options(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
- returning ::WillPaginate::Collection.new(page, per_page, total_entries) do |pager|
- options.update :offset => pager.offset, :limit => pager.per_page
+ 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) }
+ options = options.delete_if {|key, value| [:page, :per_page].include?(key) }
- pager.replace find_with_index(query, options)
- end
+ pager.replace find_with_index(query, options)
+ pager
end
end

0 comments on commit caac05e

Please sign in to comment.