fixes #6126 - deleting a subnet that is associated with a host group throws foreign key error

same thing, `before_destroy` is supposed to be before the `has_many` definitions