为什么会出现“意外的keyword_end”?

问题描述

| 我的Rails应用中有以下代码
<p id=\"notice\"><%= notice %></p>

<p>
  <b>Title:</b>
  <%= @debate.title %>
</p>

<p>
  Supporting Points:
</p>
<% @debate.supports.each.do |support| %>
<p>
  <%= support.body %>
</p>
<% end %>

<p>
  Contesting Points:
</p>
<% @debate.contests.each.do |contest| %>
<p>
  <%= contest.body %>
</p>
<% end %>
我在最后一行收到错误“语法错误,意外的keyword_end,期望$ end \”。 这是怎么回事?     

解决方法

        可能与中断的
each
循环有关,这是:
<% @debate.supports.each.do |support| %>
应该是这样的:
<% @debate.supports.each do |support| %>
请注意,我删除了\“
each
\”和\“
do
\”之间的\“
.
\”。您的
@debate.contests
循环遇到同样的问题。这将解释解析器抱怨一个杂乱的“ 8”关键字(即\“意外的keyword_end \”)。