From 67a177fbb1ce8679068dbd1df8d945cb25cd50a5 Mon Sep 17 00:00:00 2001 From: Andrew Hooker Date: Sat, 19 May 2012 21:07:42 -0500 Subject: Adding Finder Method to utilize count --- app/models/refinery/blog/category.rb | 2 +- app/models/refinery/blog/post.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'app') 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 -- cgit v1.2.3 From 4e8e71409950deb0823b4f384f9d1f323be07d8e Mon Sep 17 00:00:00 2001 From: Andrew Hooker Date: Sat, 19 May 2012 21:45:34 -0500 Subject: Removing redundant live method --- app/models/refinery/blog/post.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'app') diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb index ebe89b5..6a2d7c2 100644 --- a/app/models/refinery/blog/post.rb +++ b/app/models/refinery/blog/post.rb @@ -48,10 +48,6 @@ 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 -- cgit v1.2.3