Permalink
Browse files

Add page method to abstract search

- allows search.page(i) if a search has not already been
  executed
  • Loading branch information...
1 parent c648536 commit 966baad47bee5a129b5d94cc1a9dcd9d482464c1 Caleb Cohoon & Eric Saxby committed Dec 19, 2012
Showing with 8 additions and 0 deletions.
  1. +7 −0 lib/sunspot_with_kaminari.rb
  2. +1 −0 sunspot_with_kaminari.gemspec
View
7 lib/sunspot_with_kaminari.rb
@@ -1,3 +1,5 @@
+require 'sunspot'
+
module SunspotWithKaminari
module Search
module AbstractSearchInstanceMethods
@@ -32,6 +34,11 @@ def empty?
def any?
total > 0
end
+
+ def page(current_page)
+ query.paginate(current_page, nil)
+ self.execute.results
+ end
end
end
end
View
1 sunspot_with_kaminari.gemspec
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
s.rubyforge_project = "sunspot_with_kaminari"
+ s.add_dependency 'sunspot'
s.add_dependency 'sunspot_rails'
s.add_dependency 'kaminari', '>= 0.14.0'

0 comments on commit 966baad

Please sign in to comment.