Class: Integral::CategoriesController

Inherits:
BlogController show all
Defined in:
app/controllers/integral/categories_controller.rb

Overview

Front end categories controller

Instance Method Summary collapse

Instance Method Details

#showObject

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
  add_breadcrumb @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(options={})
  if options.is_a?(Hash) && options.include?(:category_path) && options[:category_path] == true
    "#{category_path(@resource)}?page=#{options[:page]}"
  elsif options.is_a?(Hash) && options.empty?
    category_path(@resource)
  else
    super(options)
  end
end