aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2012-02-23 00:02:15 -0800
committerPete Higgins <pete@peterhiggins.org>2012-02-23 00:02:15 -0800
commitc9ff548329cf1bbc2e82653a81a56ef57c9676c5 (patch)
treeb6b90f841c2ad20cc4f36da46bb1856700915f31 /app/models
parent5ea1b7399b627c9623c6cbd8c0b12b5fcfd9b99a (diff)
downloadrefinerycms-blog-c9ff548329cf1bbc2e82653a81a56ef57c9676c5.tar.gz
refinerycms-blog-c9ff548329cf1bbc2e82653a81a56ef57c9676c5.tar.bz2
refinerycms-blog-c9ff548329cf1bbc2e82653a81a56ef57c9676c5.zip
DRY some Refinery::Blog::Post methods.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/refinery/blog/post.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb
index 9f672c5..a4507ed 100644
--- a/app/models/refinery/blog/post.rb
+++ b/app/models/refinery/blog/post.rb
@@ -72,23 +72,19 @@ module Refinery
end
def published_dates_older_than(date)
- where("published_at <= ?", date).pluck(:published_at)
+ published_before(date).pluck(:published_at)
end
- def live
- where( "published_at <= ? and draft = ?", Time.now, false)
- end
-
def recent(count)
live.limit(count)
end
-
+
def popular(count)
unscoped.order("access_count DESC").limit(count)
end
def previous(item)
- where(["published_at < ? and draft = ?", item.published_at, false]).limit(1)
+ published_before(item.published_at).limit(1)
end
def uncategorized
@@ -101,6 +97,11 @@ module Refinery
end
end
+ def published_before(date=Time.now)
+ where("published_at < ? and draft = ?", date, false)
+ end
+ alias_method :live, :published_before
+
def comments_allowed?
Refinery::Setting.find_or_set(:comments_allowed, true, :scoping => 'blog')
end