views:

25

answers:

1

I'm learning rails and building a recipe app.

In my app, a Recipe has a bunch of ingredients.

I've got my ingredients form nested within my recipe form, and I call it with a partial.

Of course, because the form is nested, the

<%= f.submit %>
is in the recipes/_form.html.erb page.

So now I'm trying to edit a single ingredient outside the nested form. I want to use the same form though as it is still an ingredient. So I've created

<% form_for :ingredients, @ingredient, :url{:action =>'update', :id=>@ingredient.id} do |f| %>
      <% render :partial => 'form', :locals => {:f=>f} %>
     <%= f.submit %>
<% end %>

for some reason, this results in only the submit button being shown.

If I put the submit button inside the partial, it would show up within the recipe form which just isn't right.

+1  A: 

You are missing the = operator while trying to render the partial, it should be:

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

It should work, hope it helps you!

jpemberthy