aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJeff Shumate <jeff@catapulsion.net>2012-02-22 20:37:08 -0700
committerJeff Shumate <jeff@catapulsion.net>2012-02-22 20:37:08 -0700
commit4f0b5f8223426644924807fc38f86ec245f4827b (patch)
tree28f4f4f2e59ea65e6c68adf416fa8220e1404a01 /app/models
parent45cad84f4986ec9a1d78a5ced1a842f7a9048b5d (diff)
downloadrefinerycms-blog-4f0b5f8223426644924807fc38f86ec245f4827b.tar.gz
refinerycms-blog-4f0b5f8223426644924807fc38f86ec245f4827b.tar.bz2
refinerycms-blog-4f0b5f8223426644924807fc38f86ec245f4827b.zip
add popularity counter to blog posts as well as accessor for recent posts
Diffstat (limited to 'app/models')
-rw-r--r--app/models/refinery/blog/post.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb
index 822ddf7..d114dff 100644
--- a/app/models/refinery/blog/post.rb
+++ b/app/models/refinery/blog/post.rb
@@ -78,6 +78,14 @@ module Refinery
def live
where( "published_at <= ? and draft = ?", Time.now, false)
end
+
+ def recent(count)
+ where("published_at <= ? and draft = ?", Time.now, false).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)