title: Rails - :_destroy method not working
body: <p>I am trying to use :_destroy method in a nested form, but it just does not work</p>
  
  <p>There are two models:</p>
  
  <pre><code>class Setting &lt; ActiveRecord::Base
    attr_accessible :category, :name, :setting_items_attributes, :_destroy
    attr_accessor :_destroy
  
    has_many :setting_items, :dependent =&gt; :destroy
    accepts_nested_attributes_for :setting_items, :reject_if =&gt; lambda { |a| a[:content].blank? }, :allow_destroy =&gt; true
  end
  
  class SettingItem &lt; ActiveRecord::Base
    attr_accessible :setting_id, :value
    belongs_to :setting
  end
  </code></pre>
  
  <p>In the controller I create a instance:</p>
  
  <pre><code>  def edit
      @setting = Setting.find(params[:id])
      @setting.setting_items.build
    end
  </code></pre>
  
  <p>And the form looks like this:</p>
  
  <pre><code>&lt;%= form_for(@setting) do |f| %&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :category %&gt;
      &lt;%= f.text_field :category %&gt;
    &lt;/div&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :name %&gt;
      &lt;%= f.text_field :name %&gt;
    &lt;/div&gt;
    &lt;hr&gt;
    &lt;h3&gt;Params:&lt;/h3&gt;
      &lt;%= f.fields_for :setting_items do |s| %&gt;
          &lt;span&gt;
          &lt;div class="fields"&gt;
              &lt;%= s.text_field :value %&gt;
              &lt;%= s.hidden_field :_destroy %&gt;
              &lt;%= link_to_function "delete", "remove_fields(this)"%&gt;
          &lt;/div&gt;      
      &lt;% end %&gt;    
    &lt;div class="actions"&gt;
      &lt;%= f.submit "Update", :class =&gt; "btn btn-primary"%&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Also the function I use is here:</p>
  
  <pre><code>function remove_fields(link){
      $(link).prev("input[type=hidden]").val("1");
      $(link).parent().fadeOut("slow");
  }
  </code></pre>
  
  <p>So the setting_items form is simply not working at all, It shows the update is successful, but nothing is actually added or deleted.</p>