From 23abfe2c7bdbdb661efaabf6c1b83e4b101df280 Mon Sep 17 00:00:00 2001 From: Chamnap Chhorn Date: Tue, 8 Mar 2016 09:47:43 +0700 Subject: [PATCH] enh(): paginate_tag --- lib/liquid-rails/tags/paginate_tag.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/liquid-rails/tags/paginate_tag.rb b/lib/liquid-rails/tags/paginate_tag.rb index 09d2a12..9325f72 100644 --- a/lib/liquid-rails/tags/paginate_tag.rb +++ b/lib/liquid-rails/tags/paginate_tag.rb @@ -37,12 +37,12 @@ def render(context) @context = context context.stack do - collection = context[@collection_name] - raise ::Liquid::ArgumentError.new("Cannot paginate array '#{@collection_name}'. Not found.") if collection.nil? + collection = @context[@collection_name].presence || @context.environments[0][@collection_name] + raise ::Liquid::ArgumentError.new("Cannot paginate collection '#{@collection_name}'. Not found.") if collection.nil? if collection.is_a? Array paginated_collection = Kaminari.paginate_array(collection.to_a).page(current_page).per(@page_size) - elsif collection.respond_to?(:page) && collection.respond_to?(:per) + elsif collection.respond_to?(:page) paginated_collection = collection.page(current_page).per(@page_size) end