title: Using nested_form gem for in Rails, undefined method "link_to_remove/add"
body: <p>I'm trying to use the nested_form gem and I'm experiencing some problems:</p>
  
  <p><strong>The exact error:</strong> <code>undefined method link_to_remove for #&lt;ActionView::Helpers::FormBuilder:0xb57e288&gt;</code></p>
  
  <p>Here is my <strong>new.html.erb:</strong></p>
  
  <pre><code> &lt;%= javascript_include_tag :defaults, 'nested_form' %&gt;
   &lt;div class="recipe new"&gt;
     &lt;h2&gt;Add a new recipe&lt;/h2&gt;
  
     &lt;%= nested_form_for(:recipe, :url =&gt; {:action =&gt; 'create'}) do |f| %&gt;
  
       &lt;%= render(:partial =&gt; "form", :locals =&gt; {:f =&gt; f}) %&gt;
  
       &lt;br /&gt;
       &lt;br /&gt;
       &lt;div class="form-buttons"&gt;
         &lt;%= submit_tag("Create Recipe") %&gt;
       &lt;/div&gt;
  
     &lt;% end %&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>And here is the partial form, <strong>_form.html.erb</strong>:</p>
  
  <pre><code>&lt;%= javascript_include_tag :defaults, 'nested_form' %&gt;
  
  &lt;h3&gt;Recipe Name&lt;/h3&gt;
      &lt;%= f.text_field(:recipe_name) %&gt;
  
  &lt;%= fields_for :ingredient do |i| %&gt;
  &lt;table summary="Ingredient form fields"&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;Ingredient&lt;/th&gt;
      &lt;td&gt;Quantity&lt;/td&gt;
      &lt;td&gt;Measurement Unit&lt;/td&gt;
      &lt;td&gt;Total Calories&lt;/td&gt; 
      &lt;td&gt;Total Grams&lt;/td&gt;       
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;%= i.link_to_remove "Remove this ingredient" %&gt;
       &lt;td&gt;&lt;%= fields_for :food do |r| %&gt; &lt;%= r.text_field(:long_desc) %&gt;&lt;% end %&gt;&lt;/td&gt;
       &lt;td&gt;&lt;%= i.text_field(:quantity, :size =&gt; '6', :maxlength =&gt; '6') %&gt;&lt;/td&gt;
       &lt;td&gt;&lt;%= i.text_field(:units, :size =&gt; '20', :maxlength =&gt; '20') %&gt;&lt;/td&gt;
  
    &lt;/tr&gt;
  &lt;% end %&gt;
   &lt;%= i.link_to_add "Add an ingredient" %&gt;
  
    &lt;tr&gt;
  
      &lt;td&gt;&lt;%= f.text_field(:total_grams, :size =&gt; '4', :maxlength =&gt; '4') %&gt;&lt;/td&gt;    
      &lt;td&gt;&lt;%= f.text_field(:carb_calories, :size =&gt; '4', :maxlength =&gt; '4') %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= f.text_field(:fat_calories, :size =&gt; '4', :maxlength =&gt; '4') %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= f.text_field(:protein_calories, :size =&gt; '4', :maxlength =&gt; '4') %&gt;&lt;/td&gt;
  
    &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Here is the <strong>recipe.rb model</strong>:</p>
  
  <pre><code>  class Recipe &lt; ActiveRecord::Base
  
    belongs_to :user
    has_many :foods, :through =&gt; :recipe_ingredient
    has_many :recipe_ingredient
  
    accepts_nested_attributes_for :recipe_ingredient
    attr_accessible :recipe_name, :prep_time_mins, :total_grams, :carb_calories, :fat_calories, :protein_calories
    attr_accessible :recipe_ingredient_attributes
  
   end
  </code></pre>
  
  <p>And here is the <strong>recipe_ingredients.rb model:</strong></p>
  
  <pre><code># join table between each individual food item and their individual nutritional data 
  class RecipeIngredient &lt; ActiveRecord::Base
  
      belongs_to :recipe
      belongs_to :food, :foreign_key =&gt; 'ndb_no'
  
      accepts_nested_attributes_for :food
      attr_accessible :food_attributes, :quantity, :units
  end
  </code></pre>
  
  <p>Can someone give me some pointers? Thanks!</p>