This project is archived and is in readonly mode.

#6006 ✓committed
Durran Jordan

Nested Attributes: _destroy should work independent of reject_if

Reported by Durran Jordan | November 18th, 2010 @ 05:28 PM | in 3.x

Given the following model examples:

    class Man < ActiveRecord::Base
      has_many :interests
      accepts_nested_attributes_for :interests,
        :allow_destroy => true,
        :reject_if => lambda { |attrs| attrs[:topic].blank? }

    class Interests < ActiveRecord::Base
      belongs_to :man

When supplying a _destroy truthiness in the attributes hash, the record should be destroyed regardless of the return value of the reject_if. This was previously the case in Rails 3.0.0, has regressed as of 3.0.3. In our above case, the following attributes should still mark the associated record for destruction (given an Interest id of 42):

    {:interests_attributes => { :_destroy => "1", :id => 42 } }

We have attached a patch with test to fix this functionality.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>