首先感谢抽空来帮我这个新手找问题的朋友!
代码是这个样子的
<% @article.comments.each do |f| %>
<div class="col-md-12">
<h4> <%= f.email %> </h4>
<div>
<h5> <%= f.content %> </h5>
<% if signed_in? %>
<%= link_to "删除该评论", f , method: :delete , class: "btn-sm btn-primary" %>
<% end %>
</div>
</div>
<% end %>
效果让我一头雾水!
数据库是这样的,属于这篇文章的评论数是 2,字段 article_id:8
2.2.1 :003 > Comment.all
Comment Load (0.8ms) SELECT "comments".* FROM "comments" ORDER BY created_at
=> #<ActiveRecord::Relation [#<Comment id: 6, email: "[email protected]", content: "fdsaf ", article_id: 4, created_at: "2015-12-18 06:38:36", updated_at: "2015-12-18 06:38:36">, #<Comment id: 7, email: "[email protected]", content: "加入我们,现在刚刚好!直接给我私信.", article_id: 8, created_at: "2015-12-18 07:58:01", updated_at: "2015-12-18 07:58:01">, #<Comment id: 8, email: "[email protected]", content: "加入我们,现在刚刚好!直接给我私信.",article_id: 8, created_at: "2015-12-18 08:00:14", updated_at: "2015-12-18 08:00:14">]>
2.2.1 :004 > Comment.count
(0.1ms) SELECT COUNT(*) FROM "comments"
=> 3