diff options
author | Andrew Hooker <GeekOnCoffee@gmail.com> | 2012-05-19 21:07:42 -0500 |
---|---|---|
committer | Andrew Hooker <GeekOnCoffee@gmail.com> | 2012-05-19 21:07:58 -0500 |
commit | 67a177fbb1ce8679068dbd1df8d945cb25cd50a5 (patch) | |
tree | bf481771d5732d3037c9226325a42a73fc84cedf | |
parent | f4b647cc93fa0a498773a3f3146bf5f5bd017162 (diff) | |
download | refinerycms-blog-67a177fbb1ce8679068dbd1df8d945cb25cd50a5.tar.gz refinerycms-blog-67a177fbb1ce8679068dbd1df8d945cb25cd50a5.tar.bz2 refinerycms-blog-67a177fbb1ce8679068dbd1df8d945cb25cd50a5.zip |
Adding Finder Method to utilize count
-rw-r--r-- | app/models/refinery/blog/category.rb | 2 | ||||
-rw-r--r-- | app/models/refinery/blog/post.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/app/models/refinery/blog/category.rb b/app/models/refinery/blog/category.rb index 6deb5c5..2935c89 100644 --- a/app/models/refinery/blog/category.rb +++ b/app/models/refinery/blog/category.rb @@ -14,7 +14,7 @@ module Refinery attr_accessible :title def post_count - posts.select(&:live?).count + posts.live.count end # how many items to show per page diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb index 6a2d7c2..ebe89b5 100644 --- a/app/models/refinery/blog/post.rb +++ b/app/models/refinery/blog/post.rb @@ -48,6 +48,10 @@ module Refinery !draft and published_at <= Time.now end + def live + where(["published_at <= ? and draft = ?", Time.now, false]) + end + def friendly_id_source custom_url.present? ? custom_url : title end |