1
votes

I've been reading Agile Web Development with Rails and following along I'm currently on page 75/76 where you're setting up the view for the products.

I run the rails s and what I'm getting is this Exception.

*C:/Users/Win7/Desktop/Agile/depot/app/views/products/index.html.erb:25: syntax error, unexpected keyword_end, expecting ')' '); end ^ C:/Users/Win7/Desktop/Agile/depot/app/views/products/index.html.erb:34: syntax error, unexpected keyword_ensure, expecting ')' C:/Users/Win7/Desktop/Agile/depot/app/views/products/index.html.erb:36: syntax error, unexpected keyword_end, expecting ')'*

Here's the code from the view:

<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 %>

I have no idea why I'm getting this exception. Can anyone shed some light?

As always thanks a lot!

2

2 Answers

0
votes

Remove that end you have in this file:

<% end %>

This end is not closing anything.

0
votes

you are missing a ) on the line

 truncate(strip_tags(product.description), length: 80 

it should be

 truncate(strip_tags(product.description), length: 80)