Class: PostsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PostsController
- Includes:
- NotFound, WebsiteSettings
- Defined in:
- app/controllers/posts_controller.rb
Instance Method Summary collapse
Instance Method Details
#author ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/controllers/posts_controller.rb', line 15 def page = params[:page] || 1 = Character::PostAuthor.find(params[:slug]) @posts = .posts.published @posts = @posts.page(page).per(10) end |
#category ⇒ Object
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 |
#index ⇒ Object
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 |
#rss ⇒ Object
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 |
#show ⇒ Object
31 32 33 |
# File 'app/controllers/posts_controller.rb', line 31 def show @post = Character::Post.find(params[:slug]) end |