Last active
May 24, 2017 15:31
-
-
Save meltingice/a8090f51f14cf5c57ddd3cbfc244fe34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We create an index to store all of the comments in the tree, | |
# indexed by ID. This lets us quickly build out the comment structure | |
# as we iterate over each comment. | |
node_index = ActiveSupport::OrderedHash.new | |
nodes.each do |node| | |
node_index[node.id] = { | |
node: node, | |
parent: nil, | |
reply_to: nil, | |
children: [] | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment