app/controllers/refinery/blog/posts_controller.rb in refinerycms-blog-2.1.0 vs app/controllers/refinery/blog/posts_controller.rb in refinerycms-blog-3.0.1

- old
+ new

@@ -8,13 +8,16 @@ respond_to :html, :js, :rss def index if request.format.rss? - @posts = Post.live.includes(:comments, :categories) - # limit rss feed for services (like feedburner) who have max size - @posts = Post.recent(params["max_results"]) if params["max_results"].present? + @posts = if params["max_results"].present? + # limit rss feed for services (like feedburner) who have max size + Post.recent(params["max_results"]) + else + Post.newest_first.live.includes(:comments, :categories) + end end respond_with (@posts) do |format| format.html format.rss { render :layout => false } end @@ -32,14 +35,15 @@ format.js { render :partial => 'post', :layout => false } end end def comment - if (@comment = @post.comments.create(params[:comment])).valid? + @comment = @post.comments.create(comment_params) + if @comment.valid? if Comment::Moderation.enabled? or @comment.ham? begin - CommentMailer.notification(@comment, request).deliver + CommentMailer.notification(@comment, request).deliver_now rescue logger.warn "There was an error delivering a blog comment notification.\n#{$!}\n" end end @@ -72,10 +76,16 @@ end def tagged @tag = ActsAsTaggableOn::Tag.find(params[:tag_id]) @tag_name = @tag.name - @posts = Post.live.tagged_with(@tag_name).page(params[:page]) + @posts = Post.live.newest_first.uniq.tagged_with(@tag_name).page(params[:page]) + end + + private + + def comment_params + params.require(:comment).permit(:name, :email, :message) end protected def canonical? Refinery::I18n.default_frontend_locale != Refinery::I18n.current_frontend_locale