Topic: help with link_to_add_fields please!

Hi,
I need help with link_to_add_fields.
from http://railscasts.com/episodes/197-nest … orm-part-2

i dont know why, but when i click on add link i got this

<div class="fields"> <label for="building_building_photos_attributes_1313107545354_Photo">Photo</label><br/> <input id="building_building_photos_attributes_1313107545354_photo" name="building[building_photos_attributes][1313107545354][photo]" type="file" /> </div> 

if i check in firebug i see that :

&lt;div class="fields"&gt; &lt;label for="building_building_photos_attributes_1313107545354_Photo"&gt;Photo&lt;/label&gt;&lt;br/&gt; &lt;input id="building_building_photos_attributes_1313107545354_photo" name="building[building_photos_attributes][1313107545354][photo]" type="file" /&gt; &lt;/div&gt;

here is my applicationhelper

module ApplicationHelper

  def link_to_add_fields(name, f, association) 
    new_object = f.object.class.reflect_on_association(association).klass.new 
    fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| 
      render(association.to_s.singularize + "_fields", :f => builder) 
    end 
    link_to_function(name, h("add_fields(this, '#{association}', '#{escape_javascript(fields)}')")) 
    
  end
  
end 

my jquery

jQuery(function() {

    
}); 
      
function add_fields(link, association, content) {
    
  var new_id = new Date().getTime();
  var regexp = new RegExp("new_" + association, "g")
  
  $(link).parent().before(content.replace(regexp, new_id));

}

previously, i tryed nested_form with his link_to_add.. but need to change it!

thanks for your help!