From 575c2dd2812519b20836beedcb0d9493d6293d77 Mon Sep 17 00:00:00 2001 From: David Gil Date: Tue, 11 Aug 2015 19:39:52 +0200 Subject: [PATCH] faking children_count counter cache due to possible bug with awesome_nested_set --- app/models/comment.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/comment.rb b/app/models/comment.rb index 3508d5593..cac51a482 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -31,4 +31,11 @@ class Comment < ActiveRecord::Base def total_votes votes_for.size end + + # TODO: faking counter cache since there is a bug with acts_as_nested_set :counter_cache + # Remove when https://github.com/collectiveidea/awesome_nested_set/issues/294 is fixed + # There is a test for this, so you should know if it is actually fixed. + def children_count + children.count + end end