title: Why throwing abort in a nested association raises “Failed to destroy the record” exception?
body: <p>I need to validate if any CameraVectors has been associated to any MonitoredPlace before I destroy a Camera.</p>
  
  <p>Camera's Model</p>
  
  <pre><code>class Camera &lt; ApplicationRecord
    belongs_to :location
    has_many :camera_vectors, inverse_of: :camera, dependent: :destroy
  
    validates :description, :device_serial, :device_name, 
      :device_type, :device_api_url, :device_user, :device_password,
      presence: true
  
    accepts_nested_attributes_for :camera_vectors, allow_destroy: true
  end
  </code></pre>
  
  <p>CameraVector's model</p>
  
  <pre><code>class CameraVector &lt; ApplicationRecord
    belongs_to :camera, inverse_of: :camera_vectors
    belongs_to :monitored_place, optional: true
  
    validates :description, presence: true
    validates :position, numericality: { greater_than_or_equal_to: 0 }, presence: true
  
    before_destroy :has_monitored_place?
  
    private
  
    def has_monitored_place?
      if monitored_place.present?
        errors.add(:base, "cannot delete")
        throw :abort
      end
    end
  end
  </code></pre>
  
  <p>MonitoredPlace's model</p>
  
  <pre><code>class MonitoredPlace &lt; ApplicationRecord
    belongs_to :location
    belongs_to :place_type
    has_many :camera_vectors
  
    validates :place_name, presence: true
    validates :place_type_id, uniqueness: { scope: :location_id }, presence: true
  
    scope :enabled, -&gt; { where.not(enabled_on: nil).where(disabled_on: nil) }
  end
  </code></pre>
  
  <p>Because of the accepts_nested_attributes_for whenever I try to update or destroy a camera this nested fields are sent as params</p>
  
  <pre><code>"camera_vectors_attributes"=&gt;{"0"=&gt;{"description"=&gt;"A", "position"=&gt;"1", "_destroy"=&gt;"1", "id"=&gt;"47"}}
  </code></pre>
  
  <p>I thought If I wrote a callback before_destroy in the model CameraVector I could validate it, but if the validation occurs it raises ActiveRecord::RecordNotDestroyed in the controller.</p>
  
  <pre><code>if @camera.destroy(camera_params)
    redirect_to(action: :index, notice: t(".success"))
  else
    render :index
  end
  </code></pre>