0

我有一个问题,试图用资源的简写符号在 ruby​​ on rails 中渲染部分。不知何故,RoR 显示的内容与部分无关,但我也没有收到任何错误。我的意思是,生成的 HTML 看起来根本不存在对部分的调用。我也很困惑,因为我可以在日志中看到,rails 渲染了部分 2 次(那没关系,我在 dev db 中有两个测试条目),但我在浏览器中没有输出。我究竟做错了什么?提前致谢!这是我的代码:

应用程序/视图/教程/_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

1 回答 1

4

用等号试试:

<%= render :partial => @tutorials %>
于 2009-12-07T22:49:18.207 回答