From 9987dcbbe351bef1c65a4f59afaed9b745476191 Mon Sep 17 00:00:00 2001 From: Cesar Diaz Date: Wed, 2 Aug 2023 19:45:32 -0300 Subject: [PATCH] fixed error to delete tool group and its relationships --- app/controllers/tool_groups_controller.rb | 7 +++++-- app/models/tool_group.rb | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/tool_groups_controller.rb b/app/controllers/tool_groups_controller.rb index 2c62a0f87..656998473 100644 --- a/app/controllers/tool_groups_controller.rb +++ b/app/controllers/tool_groups_controller.rb @@ -52,8 +52,11 @@ def show def destroy tool_group = ToolGroup.find(params[:id]) - tool_group.destroy! - head :no_content + if tool_group.destroy! + head :no_content + else + head :not_found + end end def update diff --git a/app/models/tool_group.rb b/app/models/tool_group.rb index c45705086..03379253b 100644 --- a/app/models/tool_group.rb +++ b/app/models/tool_group.rb @@ -8,6 +8,6 @@ class ToolGroup < ApplicationRecord has_many :rule_languages, dependent: :destroy has_many :rule_countries, dependent: :destroy has_many :rule_praxes, class_name: "RulePraxis", dependent: :destroy - has_many :resource_tool_groups + has_many :resource_tool_groups, dependent: :destroy has_many :resources, through: :resource_tool_groups end