Class: Integral::CategoriesController
- Inherits:
-
BlogController
- Object
- BlogController
- Integral::CategoriesController
- Defined in:
- app/controllers/integral/categories_controller.rb
Overview
Front end categories controller
Instance Method Summary collapse
-
#show ⇒ Object
GET /:id Presents all posts with particular category.
- #url_for(options = {}) ⇒ Object
Instance Method Details
#show ⇒ Object
GET /:id Presents all posts with particular category
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/integral/categories_controller.rb', line 8 def show @resource.title, nil page_title = params[:page].present? ? "#{@resource.title} - Page #{params[:page]}" : @resource.title page_description = params[:page].present? ? "#{@resource.description} - Page #{params[:page]}" : @resource.description @meta_data = { page_title: page_title, page_description: page_description, image: @resource&.image&.url } @posts = Integral::Post.published.where(category_id: @resource.id).includes(:image).order('published_at DESC').paginate(page: params[:page]).decorate end |
#url_for(options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/integral/categories_controller.rb', line 23 def url_for(={}) if .is_a?(Hash) && .include?(:category_path) && [:category_path] == true "#{category_path(@resource)}?page=#{[:page]}" elsif .is_a?(Hash) && .empty? category_path(@resource) else super() end end |