2009-12-07 62 views
0

我有一個問題,試圖在資源管理器中使用簡短的符號表示渲染部分。不知何故,RoR顯示的只是部分內容,但我也沒有得到任何錯誤。我的意思是,最終的HTML看起來像是部分的調用根本就不存在。我也很困惑,因爲我可以在日誌中看到,軌道呈現局部2次(這可以,我在開發數據庫中有兩個測試條目),但我沒有在瀏覽器中輸出。我究竟做錯了什麼?提前致謝!這是我的代碼:RoR:部分資源

應用程序/視圖/教程/ _tutorial.html.erb:

<div class="tutorial"> 

    <h3><%= link_to tutorial.title, tutorial %></h3> 
    <span class="person"><%=h tutorial.tutor %></span> 
    <span class="time"><%=h german_time(tutorial.starts_at) %></span> 
    <span class="location"><%=h tutorial.location %></span> 
    <div class="description"><%=h tutorial.description %></div> 
    <% if admin? %> 
     <%= link_to 'Edit', edit_tutorial_path(tutorial) %> | 
     <%= link_to 'Delete', tutorial, :confirm => 'Are you sure?', :method => :delete %> 
    <% end %> 

</div> <!-- end .tutorium --> 

應用程序/視圖/教程/ index.html.erb:

<h2>Tutorials</h2> 

<% render :partial => @tutorials %> 

<% if admin? %> 
    <%= link_to 'New Tutorial', new_tutorial_path %> 
<% end %> 

控制檯日誌:

Processing TutorialsController#index (for 127.0.0.1 at 2009-12-07 23:39:00) [GET] 
    Tutorial Load (0.6ms) SELECT * FROM "tutorials" 
Rendering template within layouts/application 
Rendering tutorials/index 
Rendered tutorials/_tutorial (7.1ms) 
Rendered tutorials/_tutorial (3.7ms) 
Completed in 22ms (View: 17, DB: 1) | 200 OK [http://localhost/tutorials] 

回答

4

用等號試試:

<%= render :partial => @tutorials %> 
+0

如果您不指定<%=,它不會連續輸出流。 – jonnii 2009-12-07 22:59:28

+0

哦,男人,這樣一個愚蠢的錯誤!萬分感謝。 – 2009-12-08 00:35:42