I have shipment and invoice.
the invoice belongs to the shipment
Shipment has one invoice
If the shipment has an invoice, the shipment of the goods cannot be deleted. I need to install this in models because I use ActiveAdmin.
So, I did it in the shipment.rb file
has_one :invoice before_destroy :check_for_invoice private def check_for_invoice unless invoice.nil? self.errors[:base] << "Cannot delete shipment while its invoice exists." end end
But I just get a yellow message saying "Sending cannot be deleted", but it was actually deleted.
How can I prevent sending from being deleted?
ruby ruby-on-rails ruby-on-rails-3
leonel
source share