Created
June 24, 2011 16:58
-
-
Save lardawge/1045196 to your computer and use it in GitHub Desktop.
Override to allow sunspot to return an array that can be used by Kaminari
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sunspot | |
module Search | |
class AbstractSearch | |
private | |
def maybe_will_paginate(collection) | |
collection.instance_eval <<-RUBY, __FILE__, __LINE__ + 1 | |
def current_page | |
#{@query.page} | |
end | |
def num_pages | |
(#{total} / limit_value).ceil | |
end | |
def limit_value | |
#{@query.per_page} | |
end | |
RUBY | |
collection | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dunno if someone is still using this "patch" to add kaminari support.
On
num_pages
the way you're doing the expression is returning an integer toceil()
and it doesn't returns the expected value.You need to change to:
(#{total}.fdiv(limit_value)).ceil