Search code examples
ruby-on-railspartials

Rails not rendering a partial


I can't get my page to render a partial. When I pull run it on the server it does not render the partial at all, but just skips it. No error messages.

# 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

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

Solution

  • You need the = sign:

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

    (you had <% render ....)