[英]Syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'
I'm getting the following error on a simple test app I am working on to learns Rails. 我在一个简单的测试应用程序上遇到以下错误,我正在努力学习Rails。
syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'
It appears that it's telling be that there is an undexpected break, but I can't figure out what is wrong with my code below: 它似乎告诉我有一个意外中断,但我无法弄清楚我的代码有什么问题:
#app/views/quotations/index.html.erb
<% title "Quotations" %>
<table>
<tr>
<th>Quote Text</th>
<th>Author</th>
<th>Quote type</th>
<th>Category</th>
<th>Tags</th>
</tr>
<% for @quotations.each do |quotation| %>
<tr>
<td><%= quotation.quote_text %></td>
<td><%= quotation.author %></td>
<td><%= quotation.quote_type %></td>
<td><%= quotation.category %></td>
<td><%= quotation.tags %></td>
<td><%= link_to "Show", [@user, quotation] %></td>
<td><%= link_to "Edit", edit_user_quotation_path(@user, quotation) %></td>
<td><%= link_to "Destroy", [@user, quotation], :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<p><%= link_to "New Quotation", new_user_quotation_path(@user) %></p>
I've googled this extensively and can't figure out what's wrong with my code. 我已经广泛搜索了这个,并且无法弄清楚我的代码有什么问题。 Thanks! 谢谢!
One thing I noticed is it looks like you're mixing methodologies for looping over collections in ruby. 我注意到的一件事是,看起来你正在混合使用ruby中的集合循环的方法。 That should work if you remove the for
in the line <% for @quotations.each do |quotation| %>
如果你删除行<% for @quotations.each do |quotation| %>
中的for
,那应该有效 <% for @quotations.each do |quotation| %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.