我一直在阅读带有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 %>我不知道为什么我会得到这个例外。有人能给点线索吗?
一如既往,非常感谢!
发布于 2012-06-07 18:09:46
删除此文件中的结尾:
<% end %>这端没有关闭任何东西。
发布于 2012-06-07 18:12:56
你在电话线上漏掉了
truncate(strip_tags(product.description), length: 80 它应该是
truncate(strip_tags(product.description), length: 80) https://stackoverflow.com/questions/10936182
复制相似问题