Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm getting the following error on a simple test app I am working on to learns Rails.

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

It appears that it's telling be that there is an undexpected break, but I can't figure out what is wrong with my code below:

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

I've googled this extensively and can't figure out what's wrong with my code. Thanks!

like image 646
Edward Castaño Avatar asked Nov 03 '11 22:11

Edward Castaño


1 Answers

One thing I noticed is it looks like you're mixing methodologies for looping over collections in ruby. That should work if you remove the for in the line <% for @quotations.each do |quotation| %>

like image 51
jtrim Avatar answered Oct 16 '22 09:10

jtrim