2011-11-03 11 views
13

Recibo el siguiente error en una aplicación de prueba simple en la que estoy trabajando para aprender Rails.Error de sintaxis, inesperado ' n', esperando tCOLON2 o '[' o '.'

syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.' 

Parece que está diciendo sea que hay una ruptura undexpected, pero no puedo averiguar lo que está mal con mi código de abajo:

#app/views/quotations/index.html.erb 
<% title "Quotations" %> 

<table> 
    <tr> 
    <th>Quote Text</th> 
    <th>Author</th> 
    <th>Quote type</th> 
    <th>Category</th> 
    <th>Tags</th> 
    </tr> 
    <% for @quotations.each do |quotation| %> 
    <tr> 
     <td><%= quotation.quote_text %></td> 
     <td><%= quotation.author %></td> 
     <td><%= quotation.quote_type %></td> 
     <td><%= quotation.category %></td> 
     <td><%= quotation.tags %></td> 
     <td><%= link_to "Show", [@user, quotation] %></td> 
     <td><%= link_to "Edit", edit_user_quotation_path(@user, quotation) %></td> 
     <td><%= link_to "Destroy", [@user, quotation], :confirm => 'Are you sure?', :method => :delete %></td> 
    </tr> 
    <% end %> 
</table> 

<p><%= link_to "New Quotation", new_user_quotation_path(@user) %></p> 

He buscado en Google este extensivamente y puedo No entiendo lo que está mal con mi código. ¡Gracias!

+0

Es un error común si es nuevo con Ruby. Yo también tuve el problema ... –

Respuesta

25

Una cosa que noté es que parece que estás mezclando metodologías para recorrer las colecciones en ruby. Eso debería funcionar si elimina el for en la línea <% for @quotations.each do |quotation| %>

+1

Tienes toda la razón. Ese fue exactamente el problema. ¡Muchas gracias por su ayuda! –

Cuestiones relacionadas