Permalink
Browse files

use live scope in blog_archive_list helper method to prevent counting…

… of draft posts
  • Loading branch information...
jgrevich committed Nov 11, 2011
1 parent 329d54b commit c7615725931a1bc5992a591d4012eeca957cfced
Showing with 3 additions and 3 deletions.
  1. +3 −3 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 = '<section id="blog_archive_list"><h2>'
html << t('archives', :scope => 'blog.shared')
@@ -20,15 +20,15 @@ def blog_archive_list
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 << "<li>"
html << link_to(text, archive_blog_posts_path(:year => year, :month => month))
html << "</li>"
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 << "<li>"
html << link_to(text, archive_blog_posts_path(:year => year))

0 comments on commit c761572

Please sign in to comment.