From a8b5bce609089af8795768230c7dd3a9b87cd5e0 Mon Sep 17 00:00:00 2001 From: Philip Arndt
Date: Sat, 14 Sep 2013 10:00:42 +1200 Subject: Supported Rails 4 and Refinery 3.0.0.dev --- app/controllers/refinery/blog/categories_controller.rb | 2 +- app/controllers/refinery/blog/posts_controller.rb | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'app/controllers/refinery/blog') diff --git a/app/controllers/refinery/blog/categories_controller.rb b/app/controllers/refinery/blog/categories_controller.rb index 23a835a..b5ab574 100644 --- a/app/controllers/refinery/blog/categories_controller.rb +++ b/app/controllers/refinery/blog/categories_controller.rb @@ -3,7 +3,7 @@ module Refinery class CategoriesController < BlogController def show - @category = Refinery::Blog::Category.find(params[:id]) + @category = Refinery::Blog::Category.friendly.find(params[:id]) @posts = @category.posts.live.includes(:comments, :categories).with_globalize.page(params[:page]) end diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb index 05cd2d6..20ac12b 100644 --- a/app/controllers/refinery/blog/posts_controller.rb +++ b/app/controllers/refinery/blog/posts_controller.rb @@ -2,7 +2,7 @@ module Refinery module Blog class PostsController < BlogController - before_filter :find_all_blog_posts, :except => [:archive] + before_filter :paginate_all_blog_posts, :except => [:archive] before_filter :find_blog_post, :only => [:show, :comment, :update_nav] before_filter :find_tags @@ -10,9 +10,12 @@ module Refinery 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 @@ -34,7 +37,8 @@ module Refinery end def comment - if (@comment = @post.comments.create(params[:comment])).valid? + @comment = @post.comments.create(params[:comment]) + if @comment.valid? if Comment::Moderation.enabled? or @comment.ham? begin CommentMailer.notification(@comment, request).deliver -- cgit v1.2.3