title: Rails 3. before_destroy validation to prevent deleting parent records
body: <p>I have shipments and invoices. </p>
  
  <p>invoice belongs to shipment<br />
  shipment has one invoice</p>
  
  <p>If the shipment does have an invoice, then the shipment shouldn't be able to be deleted. I need to set this up in the models because I'm using ActiveAdmin.</p>
  
  <p>So I did this in shipment.rb</p>
  
  <pre><code>has_one :invoice
  before_destroy :check_for_invoice
  
  private
  
  def check_for_invoice
    unless invoice.nil?
      self.errors[:base] &lt;&lt; "Cannot delete shipment while its invoice exists."
    end
  end
  </code></pre>
  
  <p>But I just get a yellow message saying "Shipment cannot be deleted" but it was in fact deleted. </p>
  
  <p>How can I prevent the shipment from being deleted?</p>