Skip to content

Commit

Permalink
use live scope in blog_archive_list helper method to prevent counting…
Browse files Browse the repository at this point in the history
… of draft posts
  • Loading branch information
jgrevich committed Nov 11, 2011
1 parent 329d54b commit c761572
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 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')
Expand All @@ -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))
Expand Down

0 comments on commit c761572

Please sign in to comment.