From a3f66e19b57dac3979e9978196f874de114f1373 Mon Sep 17 00:00:00 2001 From: did Date: Sat, 5 Nov 2011 15:18:15 +0100 Subject: [PATCH] fix issue #243 (Kaminari causing error on Bushido) --- lib/locomotive.rb | 1 + lib/locomotive/kaminari.rb | 17 +++++++++++++++++ .../liquid/drops/paginatable_array.rb | 13 ------------- 3 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 lib/locomotive/kaminari.rb delete mode 100644 lib/locomotive/liquid/drops/paginatable_array.rb diff --git a/lib/locomotive.rb b/lib/locomotive.rb index 7d5c812b..71492398 100644 --- a/lib/locomotive.rb +++ b/lib/locomotive.rb @@ -6,6 +6,7 @@ require 'locomotive/core_ext' require 'locomotive/configuration' require 'locomotive/logger' require 'locomotive/dragonfly' +require 'locomotive/kaminari' require 'locomotive/liquid' require 'locomotive/mongoid' require 'locomotive/carrierwave' diff --git a/lib/locomotive/kaminari.rb b/lib/locomotive/kaminari.rb new file mode 100644 index 00000000..d54fa7da --- /dev/null +++ b/lib/locomotive/kaminari.rb @@ -0,0 +1,17 @@ +require 'kaminari' + +module Kaminari + class PaginatableArray < Array + def to_liquid(options = {}) + { + :collection => to_a, + :current_page => current_page, + :previous_page => first_page? ? nil : current_page - 1, + :next_page => last_page? ? nil : current_page + 1, + :total_entries => total_count, + :total_pages => num_pages, + :per_page => limit_value + } + end + end +end diff --git a/lib/locomotive/liquid/drops/paginatable_array.rb b/lib/locomotive/liquid/drops/paginatable_array.rb deleted file mode 100644 index 5dd738a9..00000000 --- a/lib/locomotive/liquid/drops/paginatable_array.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Kaminari::PaginatableArray - def to_liquid(options = {}) - { - :collection => to_a, - :current_page => current_page, - :previous_page => first_page? ? nil : current_page - 1, - :next_page => last_page? ? nil : current_page + 1, - :total_entries => total_count, - :total_pages => num_pages, - :per_page => limit_value - } - end -end