Class: Integral::CategoryDecorator
- Inherits:
-
Draper::Decorator
- Object
- Draper::Decorator
- Integral::CategoryDecorator
- Defined in:
- app/decorators/integral/category_decorator.rb
Overview
Category view-level logic
Instance Method Summary collapse
-
#activity_url(activity_id) ⇒ String
URL to backend activity.
-
#backend_url ⇒ String
URL to backend Image page.
-
#image_url ⇒ String
Image URL associated to the category.
-
#posts(limit = nil) ⇒ Relation
Posts associated to the category.
Instance Method Details
#activity_url(activity_id) ⇒ String
Returns URL to backend activity.
7 8 9 |
# File 'app/decorators/integral/category_decorator.rb', line 7 def activity_url(activity_id) Integral::Engine.routes.url_helpers.activity_backend_category_url(object.id, activity_id) end |
#backend_url ⇒ String
Returns URL to backend Image page.
12 13 14 |
# File 'app/decorators/integral/category_decorator.rb', line 12 def backend_url Integral::Engine.routes.url_helpers.backend_posts_url end |
#image_url ⇒ String
Returns image URL associated to the category.
22 23 24 25 26 27 28 |
# File 'app/decorators/integral/category_decorator.rb', line 22 def image_url if object.image.present? object.image.url else helpers.image_url('integral/image-not-set.png') end end |
#posts(limit = nil) ⇒ Relation
Returns posts associated to the category.
17 18 19 |
# File 'app/decorators/integral/category_decorator.rb', line 17 def posts(limit = nil) object.posts.published.order('published_at DESC').limit(limit).decorate end |