aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2012-02-10 00:38:21 -0800
committerPete Higgins <pete@peterhiggins.org>2012-02-10 01:06:05 -0800
commitaaf26e22d2feb03ebf4126e88406209239631a67 (patch)
tree600beb552164cd5c858fa57cba54dc9e838075fe /app
parent80187eac7d35a9a5ac67019a317e678c4445e44e (diff)
downloadrefinerycms-blog-aaf26e22d2feb03ebf4126e88406209239631a67.tar.gz
refinerycms-blog-aaf26e22d2feb03ebf4126e88406209239631a67.tar.bz2
refinerycms-blog-aaf26e22d2feb03ebf4126e88406209239631a67.zip
Refactor all_previous into published_dates_older_than.
Diffstat (limited to 'app')
-rw-r--r--app/helpers/refinery/blog/posts_helper.rb4
-rw-r--r--app/models/refinery/blog/post.rb4
2 files changed, 4 insertions, 4 deletions
diff --git a/app/helpers/refinery/blog/posts_helper.rb b/app/helpers/refinery/blog/posts_helper.rb
index 4653617..dfb742a 100644
--- a/app/helpers/refinery/blog/posts_helper.rb
+++ b/app/helpers/refinery/blog/posts_helper.rb
@@ -24,8 +24,8 @@ module Refinery
ArchiveWidget.new(dates, self).display
end
- def blog_archive_dates
- Refinery::Blog::Post.select('published_at').all_previous.map(&:published_at)
+ def blog_archive_dates(cutoff=Time.now.beginning_of_month)
+ Refinery::Blog::Post.published_dates_older_than(cutoff)
end
class ArchiveWidget
diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb
index 822ddf7..b6d161c 100644
--- a/app/models/refinery/blog/post.rb
+++ b/app/models/refinery/blog/post.rb
@@ -71,8 +71,8 @@ module Refinery
where(['published_at between ? and ?', archive_year.beginning_of_year, archive_year.end_of_year])
end
- def all_previous
- where(['published_at <= ?', Time.now.beginning_of_month])
+ def published_dates_older_than(date)
+ where("published_at <= ?", date).map(&:published_at)
end
def live