Apply dependent: :restrict to company model and change company controller destroy to use begin rescue ensure