adding counter_cache to comments children and WIPing on the issue

This commit is contained in:
David Gil
2015-08-11 18:43:53 +02:00
parent e880cb4f1a
commit 19ef481917
10 changed files with 66 additions and 23 deletions

View File

@@ -0,0 +1,13 @@
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
remove_column :comments, :children_count
end
end