Class: ActiveadminBlog::PostsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ActiveadminBlog::PostsController
- Defined in:
- app/controllers/activeadmin_blog/posts_controller.rb
Instance Method Summary collapse
- #archive ⇒ Object
- #category ⇒ Object
- #feed ⇒ Object
- #index ⇒ Object
- #load_categories ⇒ Object
- #search ⇒ Object
- #show ⇒ Object
- #tag ⇒ Object
Instance Method Details
#archive ⇒ Object
25 26 27 28 29 30 |
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 25 def archive month = params[:m].to_i year = params[:y].to_i @posts = ActiveadminBlog::BlogPost.published_in_month(month, year) @posts = @posts.page params[:page] end |
#category ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 19 def category category_slug = params[:slug] @posts = ActiveadminBlog::BlogPost.published_in_category(category_slug) @posts = @posts.page params[:page] end |
#feed ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 42 def feed @posts = ActiveadminBlog::BlogPost.published respond_to do |format| format.rss { render :layout => false } #index.rss.builder format.all { head :not_found } end end |
#index ⇒ Object
8 9 10 11 |
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 8 def index @posts = ActiveadminBlog::BlogPost.published @posts = @posts.page params[:page] end |
#load_categories ⇒ Object
4 5 6 |
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 4 def load_categories @categories = ActiveadminBlog::BlogCategory.all end |
#search ⇒ Object
13 14 15 16 17 |
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 13 def search search_query = params[:q] @posts = ActiveadminBlog::BlogPost.blog_search(search_query) @posts = @posts.page params[:page] end |
#show ⇒ Object
38 39 40 |
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 38 def show @post = ActiveadminBlog::BlogPost.find_by(slug:params[:slug]) end |
#tag ⇒ Object
32 33 34 35 36 |
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 32 def tag tag = params[:tag] @posts = ActiveadminBlog::BlogPost.tagged_with(tag) @posts = @posts.page params[:page] end |