Nested partial, locals, and NameError

I have a _form partial shared by new and edit actions. I render the
partials like so:

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

The partial looks (more or less) like this:

<%= f.error_messages %>

<table id="recipe_ingredients">
    <th>in units</th>
<% f.fields_for :recipe_ingredients do |ri_f| %>
  <%= render :partial => 'recipe_ingredient', :locals => { :ri_f

=> ri_f } %>
<% end %>

As you can see, I’m rendering the _recipe_ingredient partial from the
_form partial, assigning the ri_f value to the :ri_f key. The partial
looks like this:

<tr id="<%= "recipe_ingredient-#{ }"%>">
    <%= ri_f.collection_select :ingredient_id,

Ingredient.all, :id, :name %>

<%= :unit, RecipeIngredient::COOKING_UNITS %>

Problem: when I call one of the actions, I get the following error:

ActionView::TemplateError (undefined local variable or
method `ri_f' for #<ActionView::Base:0xb681ecbc>) on
line #1 of app/views/recipes/_recipe_ingredient.html.erb:
1: <tr id="<%= "recipe_ingredient-#{ }"%>">
2:   <td>
3:     <%= ri_f.collection_select :ingredient_id,

Ingredient.all, :id, :name %>

    app/controllers/recipes_controller.rb:30:in `new'

I have googled around but no luck so far… The syntax and all seems
ok, but it is refusing to work. If I move the code from the second
partial into the _form partial, it all works.

Any idea what I should correct?


Solved. Had a link_to function using the same partial (in the code I
snipped) with no locals assigned. It’s fixed now.