title: Ruby on Rails Nested Form
body: <p>I have three Models: Deal, Zipcode, DealIncludeZipcode.</p>
  
  <p>Now, the association looks like below:-</p>
  
  <p>Deal Model:</p>
  
  <pre><code>class Deal &lt; ActiveRecord::Base
    has_many  :deal_include_zipcodes, dependent: :destroy
    has_and_belongs_to_many  :zipcodes, dependent: :destroy
  
    accepts_nested_attributes_for :deal_include_zipcodes,:reject_if =&gt; :reject_include_zipcodes, allow_destroy: true
  
    private
      def reject_include_zipcodes(attributes)
        if attributes[:deal_id].blank? || attributes[:zipcode_id].blank?
          if attributes[:id].present?
            attributes.merge!({:_destroy =&gt; 1}) &amp;&amp; false
          else
            true
          end
        end
      end
  end
  
  class Zipcode &lt; ActiveRecord::Base
    has_and_belongs_to_many :deals
  end
  
  
  class DealIncludeZipcode &lt; ActiveRecord::Base
      belongs_to :deal
      belongs_to :zipcode
  end
  </code></pre>
  
  <p>Now in view I have a checkbox,on unchecking it I can select multiple zipcode to select from DealIncludeZipcode.But when I save the data it is not saving.</p>
  
  <p>I have used migration for joining Zipcode and Deal Model in which my exclude zipcode functionality is working correctly. </p>
  
  <p>Please provide a soloution.I have tried various method but didn't got succeed. </p>