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 @author = Character::PostAuthor.find(params[:slug]) @posts = @author.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 |