From c7615725931a1bc5992a591d4012eeca957cfced Mon Sep 17 00:00:00 2001 From: Justin Grevich Date: Fri, 11 Nov 2011 11:07:32 -0800 Subject: [PATCH] use live scope in blog_archive_list helper method to prevent counting of draft posts --- app/helpers/blog_posts_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/blog_posts_helper.rb b/app/helpers/blog_posts_helper.rb index 0848632..74eb521 100644 --- a/app/helpers/blog_posts_helper.rb +++ b/app/helpers/blog_posts_helper.rb @@ -1,6 +1,6 @@ module BlogPostsHelper def blog_archive_list - posts = BlogPost.select('published_at').all_previous + posts = BlogPost.live.select('published_at').all_previous return nil if posts.blank? html = '

' html << t('archives', :scope => 'blog.shared') @@ -20,7 +20,7 @@ module BlogPostsHelper links.each do |l| year = l.split('/')[1] month = l.split('/')[0] - count = BlogPost.by_archive(Time.parse(l)).size + count = BlogPost.live.by_archive(Time.parse(l)).size text = t("date.month_names")[month.to_i] + " #{year} (#{count})" html << "
  • " html << link_to(text, archive_blog_posts_path(:year => year, :month => month)) @@ -28,7 +28,7 @@ module BlogPostsHelper end super_old_links.each do |l| year = l.split('/')[1] - count = BlogPost.by_year(Time.parse(l)).size + count = BlogPost.live.by_year(Time.parse(l)).size text = "#{year} (#{count})" html << "
  • " html << link_to(text, archive_blog_posts_path(:year => year))