mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
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
This commit is contained in:
parent
57a514133b
commit
d45f11d70e
1 changed files with 13 additions and 0 deletions
13
README.md
13
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
|
||||
|
|
Loading…
Reference in a new issue