简体   繁体   English

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

[英]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.

相关问题 语法错误,意外&#39;\\ n&#39;,期待tCOLON2或&#39;[&#39;或&#39;。&#39; 当我运行rake db:migrate时 - syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.' when I run rake db:migrate 语法错误,意外&#39;,&#39;,期待tCOLON2或&#39;[&#39;或&#39;。&#39; 将课程分配给erb时 - syntax error, unexpected ',', expecting tCOLON2 or '[' or '.' when assigning a class to erb 在.erb子句中分配一个类,“语法错误,意外的tASSOC,期望的是tCOLON2” - Assigning a class in a .erb clause, “syntax error, unexpected tASSOC, expecting tCOLON2” 语法错误,意外的&#39;\\ n&#39;,期望::或&#39;[&#39;或&#39;。 - syntax error, unexpected '\n', expecting :: or '[' or '.' 语法错误,意外的&#39;\\ n&#39;,期望=&gt; - syntax error, unexpected '\n', expecting => Ruby on Rails语法错误,意外的&#39;\\ n&#39;,期望&。 或::或&#39;[&#39;或&#39;。 - Ruby on Rails syntax error, unexpected '\n', expecting &. or :: or '[' or '.' Mailer生成语法错误:意外的&#39;\\ n&#39;,期望::或&#39;[&#39;或&#39;。 - Mailer Generating Syntax Error: unexpected '\n', expecting :: or '[' or '.' 语法错误,意外的&#39;\\ n&#39;,期望=&gt;(SyntaxError) - syntax error, unexpected '\n', expecting => (SyntaxError) 语法错误,意外的tIDENTIFIER,期待&#39;;&#39; 或&#39;\\ n&#39; - syntax error, unexpected tIDENTIFIER, expecting ';' or '\n' 语法错误,意外的“ &lt;”,应为“)” - syntax error, unexpected '<', expecting ')'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM