繁体   English   中英

语法错误,意外'\\ n',期待tCOLON2或'['或'。'

[英]Syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'

我在一个简单的测试应用程序上遇到以下错误,我正在努力学习Rails。

syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'

它似乎告诉我有一个意外中断,但我无法弄清楚我的代码有什么问题:

#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>

我已经广泛搜索了这个,并且无法弄清楚我的代码有什么问题。 谢谢!

我注意到的一件事是,看起来你正在混合使用ruby中的集合循环的方法。 如果你删除行<% for @quotations.each do |quotation| %>中的for ,那应该有效 <% for @quotations.each do |quotation| %>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM