def link_to_remove(*args, &block)
      options = args.extract_options!.symbolize_keys
      options[:class] = [options[:class], "remove_nested_fields"].compact.join(" ")

      # Extracting "milestones" from "...[milestones_attributes][...]"
      md = object_name.to_s.match /(\w+)_attributes\](?:\[[\w\d]+\])?$/
      association = md && md[1]
      options["data-association"] = association

      args << (options.delete(:href) || "javascript:void(0)")
      args << options
      hidden_field(:_destroy) << @template.link_to(*args, &block)
    end
def link_to_remove(*args, &block)
      options = args.extract_options!.symbolize_keys
      options[:class] = [options[:class], "remove_nested_fields"].compact.join(" ")

      # Extracting "milestones" from "...[milestones_attributes][...]"
      md = object_name.to_s.match /(\w+)_attributes\](?:\[[\w\d]+\])?$/
      association = md && md[1]
      options["data-association"] = association

      args << (options.delete(:href) || "javascript:void(0)")
      args << options
      hidden_field(:_destroy) << @template.link_to(*args, &block)
    end
Adds a link to remove the associated record. The first argment is the name of the link.

   f.link_to_remove("Remove Task")

 You can pass HTML options in a hash at the end and a block for the content.

   <%= f.link_to_remove(:class => "remove_task", :href => "#") do %>
     Remove Task
   <% end %>

 See the README for more details on where to call this method.