1

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 Answers 2

0

Remove that end you have in this file:

<% end %>

This end is not closing anything.

Sign up to request clarification or add additional context in comments.

Comments

0

you are missing a ) on the line

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

it should be

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.