You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. Is there any way to render nested resources as JSON? I use closure_tree to implement comments with replies and the method "hash_tree" is very helpful when rendering all this heirarchy in plain HTML. But how can I render the same stuff in JSON, for example like (or anything like this - i just basically need some mechanism to mark which comments are roots, which are children and to which roots they related, in order to render it with AngularJS):
In your JSON sample it seems like your "comment" field is the descendants of the node, but there's only one direct child, which is pretty surprising. I'd expect your "comment" field (I'd rename it as "responses") would be an array holding the descendants of that node.
If those expectations were correct, I'd suggest a recursive method in your model that can render the fields you want:
Hello. Is there any way to render nested resources as JSON? I use closure_tree to implement comments with replies and the method "hash_tree" is very helpful when rendering all this heirarchy in plain HTML. But how can I render the same stuff in JSON, for example like (or anything like this - i just basically need some mechanism to mark which comments are roots, which are children and to which roots they related, in order to render it with AngularJS):
Any help will be much appreciated.
The text was updated successfully, but these errors were encountered: