app/models/forum_post.rb
# using count isn't ideal but it gives us correct caches each time
using count isn't ideal but it gives us correct caches each time
using count isn ' t ideal but it gives us correct caches each time
def update_cached_fields
    Forum.update_all ['forum_posts_count = ?', ForumPost.count(:id, :conditions => {:forum_id => forum_id})], ['id = ?', forum_id]
    topic.update_cached_post_fields(self)
    User.update_posts_count(user_id)
    if self.forum.forumable_type == "Site"
      User.update_site_posts_count(user_id)
    elsif self.forum.forumable_type == "Group"
      User.update_group_posts_count(user_id)
    end
  end
def update_cached_fields Forum . update_all [ 'forum_posts_count = ?' , ForumPost . count ( :id , :conditions => { :forum_id => forum_id } ) ] , [ 'id = ?' , forum_id ] topic . update_cached_post_fields ( self ) User . update_posts_count ( user_id ) if self . forum . forumable_type == "Site" User . update_site_posts_count ( user_id ) elsif self . forum . forumable_type == "Group" User . update_group_posts_count ( user_id ) end end
using count isn't ideal but it gives us correct caches each time
using count isn ' t ideal but it gives us correct caches each time