creddit/app/helpers/comments_helper.rb

12 lines
364 B
Ruby
Raw Normal View History

2015-12-11 15:26:51 -05:00
# helpers/comments_helper.rb
2015-07-16 11:57:27 -04:00
module CommentsHelper
def nested_comments(comments)
comments.map do |comment, sub_comments|
2015-12-11 15:26:51 -05:00
render(comment, post: comment.post, subcreddit: comment.post_subcreddit) +
2015-07-16 11:57:27 -04:00
content_tag(:div,
nested_comments(sub_comments),
class: 'nested_comments')
end.join.html_safe
end
end