0
在此之后SO post,我试图渲染使用acts_as_tree轨,但没有成功插件缩进意见。渲染嵌套/线程评论
我认为问题在于这种方法(我不明白):
def indented_render(num, *args)
render(*args).gsub(/^/, "\t" * num)
end
这是什么方法替代品?我的部分如下:
%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
但是,没有一行是缩进的。我究竟做错了什么?有没有更好的方法来呈现评论?
更新:这是生成的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>
不,根本没有标签。我附上了我的html的样子。 – David 2011-05-08 08:31:20
我想我明白了。我有'thread-> comments'(2个不同的模型),我不知道如何以这种方式显示整个线程历史记录,所以我做了一个虚拟根注释并将它作为线程注释的父项('thread-> root_comment-> comments')。有没有更好的方法来做到这一点? – David 2011-05-09 09:29:21