Blog-索引页上的评论计数
|
我正在尝试在索引页面而不是文章页面上的文章旁边显示一个“总评论”数(即7)。是否想为此使用ruby方法,因为它可能是最直接的方法...?
views / articles / _article.html.erb
<div class=\"article_header\">
<b>Title: </b> <%= truncate(article.title, :length => 50) %>
by <%= article.user.username %> on <%= article.created_at.strftime(\"%d %B, %Y\") %>
<b>Detail:</b> <%= truncate(article.body, :length => 225) %>
</div>
<br />
<%= blog.comments.count %>
<%= link_to \'Read\', article %>
<% if can? :update, article %>
| <%= link_to \'Edit\', edit_article_path(article) %> |
<% end %>
没有找到相关结果
已邀请:
2 个回复
磐乓铝举
然后在您的部分:
芭隘的盘石
这只会在索引页面的输出中添加另一列。如果您只想显示计数,则不必链接它: