Created
December 22, 2011 07:24
-
-
Save rust/1509352 to your computer and use it in GitHub Desktop.
lib/kaminari_patch.rb
This file contains hidden or 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
= paginator.render do | |
%div | |
= prev_page_tag | |
= (current_page.to_i - 1) * per_page + 1 | |
\- | |
= [current_page.to_i * per_page, total_count].min | |
\/ | |
= total_count | |
件 | |
= next_page_tag |
This file contains hidden or 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 Kaminari | |
module ActionViewExtension | |
def paginate(scope, options = {}, &block) | |
paginator = Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false, :total_count => scope.total_count) | |
paginator.to_s | |
end | |
end | |
end |
amatsuda
commented
Dec 22, 2011
In paginate views (app/views/kaminari/_paginate.html.haml), I can't use collection method, such as total_count . So in order to use such method, I use this patch that assigns total_count as :locals in partial view.
Ugh. I haven't noticed that people need total_count in views, but yes, probably that's kaminari's fault.
Feel free to raise an issue or PR if you need to put that feature in kaminari core. Thank you!
Thanks for this!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment