Created
May 23, 2017 21:19
-
-
Save meltingice/bfb16f8578599dd9bd6ed626e1d7fd4b 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 use includes(:member) to solve one of the N+1 issues by loading | |
# all of the members in a single query. | |
serialized_comments = article. | |
comments. | |
includes(:member). | |
arrange_serializable do |comment, children| | |
# This block is invoked for every node in the tree, which lets us | |
# build out a tree of serialized comments. | |
Api::V1::CommentSerializer.new(comment, children: children) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment