diff --git a/app/models/comment.rb b/app/models/comment.rb index f298c67c3..696b363ce 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -34,7 +34,8 @@ class Comment < ActiveRecord::Base # 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. + # and reset counters using + # > Comment.find_each { |comment| Comment.reset_counters(comment.id, :children) } def children_count children.count end diff --git a/db/migrate/20150811161459_add_children_count_to_comments.rb b/db/migrate/20150811161459_add_children_count_to_comments.rb index 74c288ff5..ce233542d 100644 --- a/db/migrate/20150811161459_add_children_count_to_comments.rb +++ b/db/migrate/20150811161459_add_children_count_to_comments.rb @@ -1,10 +1,6 @@ class AddChildrenCountToComments < ActiveRecord::Migration def up add_column :comments, :children_count, :integer, default: 0 - - Comment.find_each do |comment| - Comment.reset_counters(comment.id, :children) - end end def down