2011-11-03 11 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> 

मैं इस बड़े पैमाने पर googled और कर सकते हैं किया है यह पता नहीं है कि मेरे कोड में क्या गलत है। धन्यवाद!

+0

में हटा दें तो यह काम करना चाहिए यदि आप रूबी के लिए नए हैं तो यह एक आम गलती है। मुझे भी समस्या थी .. –

उत्तर

25

एक बात मैंने देखी है ऐसा लगता है कि आप रूबी में संग्रहों पर लूपिंग के लिए मिश्रण पद्धतियां कर रहे हैं। यदि आप को <% for @quotations.each do |quotation| %>

+1

आप बिल्कुल सही हैं। वह बिल्कुल समस्या थी। आपकी मदद के लिए बहुत धन्यवाद! –

संबंधित मुद्दे