+2  A: 

You have

/recipe/:recipe_id/ingredient/:ingredient_id/edit

which is a route to edit an existing ingredient. But your form

<%= form_for([@recipe, @recipe.ingredients.build]) do |f| % >

is expecting you to build a new ingredient which belongs to @recipe.

If you want to edit an existing ingredient then you need to get it using your params.

@recipe = Recipe.find params[:recipe_id]
@ingredient = @recipe.ingredients.find params[:ingredient_id]
<%= form_for([@recipe, @ingredient]) do |f| % >    

I don't really know what example you're following but I guess an ingredient is a many to many join between recipe and (say) food? If that is the case, and ingredient belongs to a recipe rather than many recipes then you can do this:

/ingredient/:ingredient_id/edit
@ingredient = Ingredient.find params[:ingredient_id]
@recipe = @ingredient.recipe

and thus:

<%= form_for(@ingredient) do |f| % >    

further suggestion:

I can't say for sure without seeing all your template but are you doing something like:

<%- form_for @item do |f| -%>
  <%= f.fields_for :field -%>

 <%- form_for @different_item do |ff| -%>
   <%= ff.fields_for :another_field  -%>
 <%- end -%>

<%- end -%>

Actually, can you post the gist of your form as above.

mark
thanks mark, I think the problem I'm getting at is that if I use the form_for(@ingredient) it breaks the nested recipe form, if I use form_for([@recipe, @recipe.ingredients.build]) it breaks the non-nested form. The forms are actually the same, so I was thinking I shouldn't be recreating the form_for, or should I remove form_for from the partial, and just have the rest of the form in the partial?
pedalpete
Quick suggestion added to answer.
mark
I added my form and maybe template to the question. It doesn't look like the update you posted.
pedalpete