Class: Comfy::Blog::PostsController

Inherits:
Cms::BaseController
  • Object
show all
Includes:
Paginate
Defined in:
app/controllers/comfy/blog/posts_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/comfy/blog/posts_controller.rb', line 5

def index
  scope =
    if params[:year]
      scope = @cms_site.blog_posts.published.for_year(params[:year])
      params[:month] ? scope.for_month(params[:month]) : scope
    else
      @cms_site.blog_posts.published
    end

  scope = scope.for_category(params[:category]) if params[:category]

  @blog_posts = comfy_paginate(scope, per_page: ComfyBlog.config.posts_per_page)
  render layout: ComfyBlog.config.app_layout
end

#showObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/comfy/blog/posts_controller.rb', line 20

def show
  load_post

  render  inline: @cms_post.content_cache,
          layout: app_layout,
          content_type: "text/html"

rescue ActiveRecord::RecordNotFound
  render cms_page: "/404", status: 404
end