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

Edw*_*año 13 ruby-on-rails syntax-error

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

syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'
Run Code Online (Sandbox Code Playgroud)

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

#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>
Run Code Online (Sandbox Code Playgroud)

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

jtr*_*rim 25

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