Class: PostsController

Inherits:
ApplicationController
  • Object
show all
Includes:
NotFound, WebsiteSettings
Defined in:
app/controllers/posts_controller.rb

Instance Method Summary collapse

Instance Method Details

#authorObject



15
16
17
18
19
20
21
# File 'app/controllers/posts_controller.rb', line 15

def author
  page = params[:page] || 1

  @author = Character::PostAuthor.find(params[:slug])
  @posts = @author.posts.published
  @posts = @posts.page(page).per(10)
end

#categoryObject



23
24
25
26
27
28
29
# File 'app/controllers/posts_controller.rb', line 23

def category
  page = params[:page] || 1

  @category = Character::PostCategory.find(params[:slug])
  @posts = @category.posts.published
  @posts = @posts.page(page).per(10)
end

#indexObject



5
6
7
8
9
10
11
12
13
# File 'app/controllers/posts_controller.rb', line 5

def index
  page             = params[:page] || 1
  @search          = params[:q] || ''
  @kaminari_params = @search.empty? ? {} : { q: @search }

  @posts = Character::Post.published
  @posts = @posts.search(@search) if not @search.empty?
  @posts = @posts.page(page).per(10)
end

#rssObject



35
36
37
38
39
40
41
42
# File 'app/controllers/posts_controller.rb', line 35

def rss
  page = params[:page] || 1
  @posts = Character::Post.published.page(page).per(10)

  respond_to do |format|
    format.all { render :layout => false, content_type: 'text/xml; charset=utf-8' }
  end
end

#showObject



31
32
33
# File 'app/controllers/posts_controller.rb', line 31

def show
  @post = Character::Post.find(params[:slug])
end