From cfb65dd05610e0c934af4c4a7a02aae9c7508ba0 Mon Sep 17 00:00:00 2001 From: Fu Matthew Date: Thu, 27 Dec 2012 10:20:37 +0800 Subject: [PATCH] Preventing site default design being deleted. --- app/controllers/admin/designs_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 913520fa..a661a5c1 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -94,7 +94,12 @@ class Admin::DesignsController < OrbitBackendController def destroy @design = Design.find(params[:id]) - @design.destroy + if @site.design == @design + flash[:error] = "Failed! You can not delete a design that used by default " + else + @design.destroy + flash[:notice] = "Successfully deleted design." + end redirect_to admin_designs_url end