diff options
author | djones <dgjones@gmail.com> | 2010-09-21 17:20:08 +1200 |
---|---|---|
committer | djones <dgjones@gmail.com> | 2010-09-21 17:20:08 +1200 |
commit | f036f2a46f5c085505aff507f54518df8e283069 (patch) | |
tree | 5dd5bd48059066ceb0fef489d33e42d93e15c5df /app/models/blog_category.rb | |
parent | 18b2db513d5241738135cfd330e730c63abec277 (diff) | |
download | refinerycms-blog-f036f2a46f5c085505aff507f54518df8e283069.tar.gz refinerycms-blog-f036f2a46f5c085505aff507f54518df8e283069.tar.bz2 refinerycms-blog-f036f2a46f5c085505aff507f54518df8e283069.zip |
added publish date support. fixes bug where categories were showing posts that were technically supposed to be hidden from the end user
Diffstat (limited to 'app/models/blog_category.rb')
-rw-r--r-- | app/models/blog_category.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/models/blog_category.rb b/app/models/blog_category.rb index 09d32de..c78a7a4 100644 --- a/app/models/blog_category.rb +++ b/app/models/blog_category.rb @@ -8,5 +8,16 @@ class BlogCategory < ActiveRecord::Base validates_uniqueness_of :title has_friendly_id :title, :use_slug => true - + + # this might be able to be optimised a little more + def post_count + count = 0 + + self.posts.each do |p| + count += 1 if p.live? + end + + count + end + end |