title: Why is destroying nested records happening on update_attributes and not on the parent save?
body: <p>I have two associated models:</p>
  
  <pre><code>class HelpRequest &lt; ActiveRecord::Base
    has_many :donation_items, dependent: :destroy
    accepts_nested_attributes_for :donation_items, allow_destroy: true
  </code></pre>
  
  <p>and</p>
  
  <pre><code>class DonationItem &lt; ActiveRecord::Base
    belongs_to :help_request
  </code></pre>
  
  <p>I have a validator that returns an error to the user if he/she tries to save a <code>help_request</code> with no <code>donation_items</code>.</p>
  
  <pre><code>validate :has_donation_items?
  ...
  def has_donation_items?
    if !self.donation_items.present?
      errors.add :a_help_request, "must have at least one item."
    end
  end
  </code></pre>
  
  <p>I'm updating both the <code>help_request</code> and the <code>donation_items</code> from within a nested form in which the user can destroy single or multiple <code>donation_items</code>. According to <a href="http://apidock.com/rails/ActiveRecord/NestedAttributes/ClassMethods" rel="nofollow">this</a>, if the user destroys any <code>donation_items</code> they shouldn't get destroyed in the database until the parent is saved. But I've verified that in my case, they're being destroyed immediately upon running the <code>update_attributes</code> method. Here's stripped down code:</p>
  
  <pre><code>@help_request.update_attributes(help_request_params) # donation items get destroyed in the database right here
  # do some stuff
  if @help_request.save
    #do some other stuff if the save is successful
  </code></pre>
  
  <p>Here's the <code>help_request_params</code> with nested attributes:</p>
  
  <pre><code>def help_request_params
    params.require(:help_request).permit(:id, :name, :description, :event_flag, :due_on_event, :date, :time, :send_notification, :event_id, :invoked, donation_items_attributes: [:id, :name, :amount, :_destroy])
  end
  </code></pre>
  
  <p>Is there a reason why the database seems to be getting updated on <code>update_attributes</code>?</p>