我正在开始使用Rails指南,网址为http://guides.rubyonrails.org/getting_started.html,我已经到了5.8的最后一部分。我的输出包含这个额外的行,我不知道它来自哪里。有人可以帮我吗?为什么我的erb代码在教程不会导致时间戳?
[#<Article id: 1, title: "Test", text: "tests", created_at: "2017-01-17 20:01:14", updated_at: "2017-01-17 20:01:14">]
教程码 -
<h1>Listing articles</h1>
<table>
<tr>
<th>Title</th>
<th>Text</th>
</tr>
<% @articles.each do |article| %>
<tr>
<td><%= article.title %></td>
<td><%= article.text %></td>
<td><%= link_to 'Show', article_path(article) %></td>
</tr>
<% end %>
</table>
我的代码是这样的 -
<div>
<%= @articles.each do |article| %>
<div>
<div>Title:</div>
<div><%= article.title %></div>
<div>Text:</div>
<div><%= article.text %></div>
<div><%= link_to 'Show', article_path(article) %></div>
</div>
<% end %>
</div>
谢谢,无法相信我错过了我发布的问题相比之前的10倍左右。作为一个利益问题,为什么<%=在这里的作用与<%不同? – SMC
看看[这个SO问题](http://stackoverflow.com/questions/7996695/what-is-the-difference-between-and-in-erb-in-rails)。 – mmichael