Module: MongoidForums::ForumsHelper

Defined in:
app/helpers/mongoid_forums/forums_helper.rb

Instance Method Summary collapse

Instance Method Details

#posts_count(forum) ⇒ Object


7
8
9
10
11
12
13
# File 'app/helpers/mongoid_forums/forums_helper.rb', line 7

def posts_count(forum)
  if forum.posts_count == nil
    forum.posts_count = forum.topics.inject(0) {|sum, topic| topic.posts.count + sum }
    forum.save
  end
  forum.posts_count
end

#topics_count(forum) ⇒ Object


3
4
5
# File 'app/helpers/mongoid_forums/forums_helper.rb', line 3

def topics_count(forum)
  forum.topics.count
end