aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/blog_category.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/blog_category.rb')
-rw-r--r--app/models/blog_category.rb13
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