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

时间:2021-11-10 20:11:35

total newbie trying to work through the rails tutorial on lynda.com

总新手试图通过lynda.com上的rails教程

The code is really short and exactly the way it is on the video, yet I can't get my page to render the partial. When I pull run it on the server it does not render the partial at all, but just skips it. No error messages. Thanks in advance

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

this is edit.html.erb

这是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>

and this is _form.html.erb

这是_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 个解决方案

#1


33  

You need the = sign:

你需要=符号:

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

(you had <% render ....)

(你有<%render ....)

#1


33  

You need the = sign:

你需要=符号:

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

(you had <% render ....)

(你有<%render ....)