2009-12-07 48 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