2010-07-30 15 views
1

我以爲我正在關注這個RoR教程,但顯然不是。他們指示我們寫代碼到apps/views/index.html.erbRails Index.html.erb行爲不端

<h1>Listing posts</h1> 

<table> 
    <tr> 
     <th>Name </th> 
     <th>Title </th> 
     <th>Content </th> 
    </tr> 

<% for post in @posts %> 
    <tr> 
     <td><%=h post.name %></td> 
     <td><%=h post.title %></td> 
     <td><%=h post.content %></td> 

     <td><%= link_to'Show', post     %></td> 
     <td><%= link_to 'Edit', edit_post_path(post) %></td> 
     <td><%= link_to 'Destroy', post, 
       :confirm => 'Are you sure?', 
       :method => :delete     %></td> 
    </tr> 
<% end %> 
</table> 

<br /> 

<% link_to 'New Post', new_post_path %> 

它踢回一圈輸入10次錯誤,但我沒有確切的問題是什麼太清楚。有人能爲我發現一些情況嗎?

的錯誤是

syntax error, unexpected ')', expecting kDO_COND or ':' or '\n' or ';' 
....concat((for post in @posts).to_s); @output_buffer.concat ... 
+0

有什麼錯誤? – 2010-07-30 04:52:45

+0

錯誤無益。我把它貼在上面。 – Andy 2010-07-30 04:56:50

回答

3

只要@posts是有屬性nametitlecontent對象(大概Post對象)的一個集合,您對資源產生標準的REST風格的路線, 您的看法很好。看看你的控制器。

編輯:的對...在語法需要做的。 for post in @posts do ...

所以錯誤是有幫助 - 關於KDO位...

相關問題