【发布时间】:2012-06-07 16:44:17
【问题描述】:
我一直在阅读使用 Rails 进行敏捷 Web 开发,我目前在第 75/76 页上为产品设置视图。
我运行 rails 得到的是这个异常。
*C:/Users/Win7/Desktop/Agile/depot/app/views/products/index.html.erb:25: 语法错误,出乎意料的keyword_end,期待')' ');结尾 ^ C:/Users/Win7/Desktop/Agile/depot/app/views/products/index.html.erb:34: 语法错误,意外的keyword_ensure,需要')' C:/Users/Win7/Desktop/Agile/depot/app/views/products/index.html.erb:36: 语法错误,意外的keyword_end,需要')'*
这是视图中的代码:
<h1>Listing products</h1>
<table>
<% @products.each do |product| %>
<tr class="<%= cycle('list_line_odd', 'list_line_even') %>">
<td>
<%= image_tag(product.image_url, class: 'list_image') %>
</td>
<td class="list_description">
<dl>
<dt><%= product.title %></dt>
<dd><%= truncate(strip_tags(product.description), length: 80 %></dd>
</dl>
</td>
<td class="list_actions">
<%= link_to 'Show', product %><br />
<%= link_to 'Edit', edit_product_path(product) %><br />
<%= link_to 'Destroy', product, confirm: 'Are you sure?', method: :delete %>
</td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Product', new_product_path %>
我不知道为什么会出现此异常。有人能解释一下吗?
一如既往,非常感谢!
【问题讨论】:
标签: ruby-on-rails