From 70589b9d517184bd91c43874e467cd12da03e33f Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 13 Oct 2015 19:11:21 +0800 Subject: [PATCH] added delete builing button --- app/controllers/admin/spaces_controller.rb | 7 +++++++ app/views/admin/spaces/_building.html.erb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/spaces_controller.rb b/app/controllers/admin/spaces_controller.rb index e0c3a39..791a7c7 100644 --- a/app/controllers/admin/spaces_controller.rb +++ b/app/controllers/admin/spaces_controller.rb @@ -19,6 +19,13 @@ class Admin::SpacesController < OrbitAdminController redirect_to admin_spaces_path end + def destroy + uid = params[:id].split("-").last + building = Building.find_by(:uid => uid) rescue nil + building.destroy if !building.nil? + redirect_to admin_spaces_path + end + def update uid = params[:id].split("-").last building = Building.find_by(:uid => uid) rescue nil diff --git a/app/views/admin/spaces/_building.html.erb b/app/views/admin/spaces/_building.html.erb index 1738c7b..3cc3915 100644 --- a/app/views/admin/spaces/_building.html.erb +++ b/app/views/admin/spaces/_building.html.erb @@ -5,6 +5,6 @@

<%= building.title %>

- Edit | Delete + Edit | Delete
\ No newline at end of file