簡體   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