我试图做一个博客文章的评论部分,其中下面列出了评论意见。如何清理我的视图
我有Posts
和PostComments
类
我posts/show.html.erb
显示博客文章,我已经做了post_comments/_post_comment.html.erb
部分来呈现评论中posts/show.html.erb
我有以下几点:
<% @post.post_comments.each do |comment| %>
<%= render :partial => '/post_comments/post_comment', :locals=>{ :comment => comment } %>
<% end %>
有什么办法可以将视图中的循环移出控制器中的方法吗?我想调用它的will_paginate,如果逻辑在视图中,我不认为我可以这样做。
我不使用红宝石,但您的当前方法似乎是用模板迭代内容的最佳方法。 – Stephen 2010-11-03 17:54:17