Rails不会在网页上呈现部分内容

时间:2011-10-28 22:26:19

标签: ruby-on-rails partials

总新手试图通过lynda.com上的rails教程进行工作

代码非常简短,与视频完全一样,但我无法让我的页面呈现部分。当我在服务器上运行它时,它根本不会渲染部分,而只是跳过它。没有错误消息。提前致谢

这是edit.html.erb

<%= link_to("<< Back to List", {:action => 'list'}, :class => 'back=link')%>

<div class="subject edit">
    <h2>Edit Subject</h2>

    <%= form_for(:subject, :url => {:action => 'update', :id=>@subject.id}) do |f| %>

        <% render :partial => 'form', :locals => {:f => f} %>

        <div class="form-buttons">
            <%= submit_tag("Update Subject")%>
        </div>

    <% end %>
</div>

这是_form.html.erb

<table summary="Subject form fields">
    <tr>
        <th>Name</th>
        <td><%= f.text_field(:name) %></td>
    </tr>
    <tr>
        <th>Position</th>
        <td><%= f.text_field(:position) %></td>
    </tr>
    <tr>
        <th>Visible</th>
        <td><%= f.text_field(:visible) %></td>
    </tr>
</table>

1 个答案:

答案 0 :(得分:35)

您需要=标志:

<%= render :partial => 'form', :locals => {:f => f} %>

(你有<% render ....