为什么我的erb代码没有教程时会导致时间戳记? [英] Why does my erb code result in timestamps when tutorial doesn't?
本文介绍了为什么我的erb代码没有教程时会导致时间戳记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在 http://guides.rubyonrails.org/上使用Rails入门指南。 Getting_started.html ,我到了5.8的最后一部分。我的输出包含这条额外的行,我无法确定它的来源。有人可以帮我吗?
I'm doing the Getting Started with Rails guide at http://guides.rubyonrails.org/getting_started.html and I'm up to the last section of 5.8. My output contains this additional line and I can't figure out where it comes from. Can someone help me out?
[#<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>
推荐答案
删除 =
<%= @articles.each do |article| %>
应该是
<% @articles.each do |article| %>
这篇关于为什么我的erb代码没有教程时会导致时间戳记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文