2011-11-03 2 views
13

레일즈를 배우기 위해 간단한 테스트 앱에서 다음과 같은 오류가 나타납니다.구문 오류, 예상치 못한 ' n', 예상 tCOLON2 또는 '['또는 '.'

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

그것은 undexpected 휴식이 있다는 것을있을 말하고,하지만 아래에있는 내 코드에 어떤 문제가 있는지 알아낼 수 없습니다 나타납니다 :

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

내가 할 수 광범위하게이 인터넷 검색 및했습니다 내 코드가 무엇이 잘못되었는지 파악하지 마라. 감사!

+0

Ruby를 처음 사용하는 경우 일반적인 실수입니다. 나도 문제가 있었어. –

답변

25

내가 알아챈 한 가지는 루비의 컬렉션을 반복하는 방법론을 혼합 한 것처럼 보입니다. 줄에서 for을 제거하면 작동합니다. <% for @quotations.each do |quotation| %>

+1

당신은 틀리지. 그것은 정확히 문제였습니다. 도와 줘서 고마워! –

관련 문제