Topic: Problems following Agile Web Development with Rails

Hi guys,

I have the 3.1 edition of AWDWR, I've been following along correctly and I'm only a very short way into the book actually page 75/76 where they're demonstrating how to edit the index.html.erb view for products... Basically, it's a simple case of me reading and understanding what they're showing me (which of course I do) and then writing the code into my text editor myself.

I do that, double check it and go into my console and type rails s

I go into chrome and load up localhost:3000/products but what I get is this;


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:32: syntax error, unexpected keyword_ensure, expecting ')'
C:/Users/Win7/Desktop/Agile/depot/app/views/products/index.html.erb:34: syntax error, unexpected keyword_end, expecting ')'

It's trying to tell me that the <% end %> shouldn't be there, which makes absolutely no sense. Have any of you experienced this problem following the book?

Re: Problems following Agile Web Development with Rails

Post index.html.erb code to see what causes the error.

Re: Problems following Agile Web Development with Rails

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

Last edited by Dacu (2012-06-05 09:44:31)

Re: Problems following Agile Web Development with Rails

So any ideas guys?

Re: Problems following Agile Web Development with Rails

I suggest you to use Rails in Linux environment.

it will be easier and you'll find much more tutorials out there

Re: Problems following Agile Web Development with Rails

Hmm that should work. Do you have anything in your layout that would be causing this??

Also just for shizzles and giggles try changing:
<% @products.each do |product| %>

to:
<% for product in @products %>

Although yours should work.

Re: Problems following Agile Web Development with Rails

I know this is an old topic, but the issue was this line:
<dd><%= truncate(strip_tags(product.description), length: 80 %></dd>

You were missing a second closing )