Following this SO post, I am trying to render indented comments using the acts_as_tree rails plugin with no success.
I believe the problem lies with this method (which I don't understand):
def indented_render(num, *args)
render(*args).gsub(/^/, "\t" * num)
end
What does this method substitute? My partial is as follows:
%div{:id => "comment_#{comment.id}"}
= comment.body
= render :partial => 'comments/comment', :collection => comment.children
- unless comment.children.empty?
= indented_render 1, :partial => 'comments/comment', :collection => comment.children
However, none of the lines are indented. What am I doing wrong? Is there a better way to render the comments?
Update: This is the generated html:
<h1>Listing comments</h1>
<table>
<tr>
<td>
<div id='comment_1'>
(152) Facebook version of you: 400 friends. Real version of you: 4 friends
<div id='comment_2'>
(0) Well played.
<div id='comment_3'>
(0) I used to. Then I got married.
<div id='comment_4'>
(17) math is hard
<div id='comment_5'>
(1) What's a math?
<div id='comment_6'>
(1) This made coke come out my nose.
<div id='comment_7'>
(2) So maybe I wasn't the best with fractions.
</div>
<div id='comment_8'>
(1) That sounds terribly painful. Please accept my apologies. Isn't it supposed to be going in your nose, not out?
</div>
</div>
</div>
</div>
</div>
</div>
</div>