From d45f11d70e620fcd09f877bfe83d8c6f5cc68c52 Mon Sep 17 00:00:00 2001 From: Rennan Oliveira Date: Tue, 22 Mar 2016 18:01:06 -0300 Subject: [PATCH] Adding collection_decorator_class to README.md Adding how to use a PaginatingDecorator (extending Draper::CollectionDecorator) on a class extending Draper::Decorator to README.md This explains how to use ArticleDecorator.decorate_collection(@articles.paginate(page: params[:page])) and have your @articles respond to pagination methods whilst individual articles get decorated --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 80009a5..c09531a 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,19 @@ omitted. delegate :current_page, :per_page, :offset, :total_entries, :total_pages ``` +If needed, you can then set the collection_decorator_class of your CustomDecorator as follows: +```ruby +class ArticleDecorator < Draper::Decorator + def self.collection_decorator_class + PaginatingDecorator + end +end + +ArticleDecorator.decorate_collection(@articles.paginate) +# => Collection decorated by PaginatingDecorator +# => Members decorated by ArticleDecorator +``` + ### Decorating Associated Objects You can automatically decorate associated models when the primary model is