Class: Blog::PostsController
- Inherits:
-
BlogController
- Object
- BlogController
- Blog::PostsController
- Includes:
- BlogHelper, SettingsHelper
- Defined in:
- app/controllers/blog/posts_controller.rb
Overview
Name: Posts controller Use: Creating , modifying, deleting blog posts for the cms Created date: 08-06-2012 Modified Date:
Instance Method Summary collapse
-
#archive ⇒ Object
archive method for listing archived blog posts.
- #comment ⇒ Object
-
#tagged ⇒ Object
tagged method for listing tagged blog posts.
Methods included from BlogHelper
#blog_archive_list, #blog_post_teaser, #next_or_previous?
Methods included from SettingsHelper
#blog_posts_per_page, commentable, moderatable, uncommentable, unmoderatable
Instance Method Details
#archive ⇒ Object
archive method for listing archived blog posts
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/controllers/blog/posts_controller.rb', line 67 def archive if params[:month].present? date = "#{params[:month]}/#{params[:year]}" @archive_date = Time.parse(date) @date_title = @archive_date.strftime('%B %Y') @blog_posts = BlogPost.live.by_archive(@archive_date).paginate({ :page => params[:page], :per_page => blog_posts_per_page }) else date = "01/#{params[:year]}" @archive_date = Time.parse(date) @date_title = @archive_date.strftime('%Y') @blog_posts = BlogPost.live.by_year(@archive_date).paginate({ :page => params[:page], :per_page => blog_posts_per_page }) end respond_with (@blog_posts) end |
#comment ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/blog/posts_controller.rb', line 32 def comment @blog_post = BlogPost.find(params[:id]) if (@blog_comment = @blog_post.comments.create(params[:blog_comment])).valid? if BlogComment::Moderation.enabled? or @blog_comment.ham? begin Blog::CommentMailer.notification(@blog_comment).deliver rescue logger.warn "There was an error delivering a blog comment notification.\n#{$!}\n" end end if BlogComment::Moderation.enabled? flash[:notice] = t('blog.posts.comments.thank_you_moderated') redirect_to blog_post_url(params[:id]) else flash[:notice] = t('blog.posts.comments.thank_you') redirect_to blog_post_url(params[:id], :anchor => "comment-#{@blog_comment.to_param}") end else render :action => 'show' end end |
#tagged ⇒ Object
tagged method for listing tagged blog posts
57 58 59 60 61 62 63 64 |
# File 'app/controllers/blog/posts_controller.rb', line 57 def tagged @tag = ActsAsTaggableOn::Tag.find(params[:tag_id]) @tag_name = @tag.name @blog_posts = BlogPost.tagged_with(@tag_name).paginate({ :page => params[:page], :per_page => blog_posts_per_page }) end |