From c620d1fc1e53aea2f0db6388e67590485b2fd6d7 Mon Sep 17 00:00:00 2001 From: Tony Vincent Date: Thu, 20 Feb 2025 15:03:30 +0100 Subject: [PATCH] fix: Ghost subcategories when parent category is deleted (#1874) --- app/models/category.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/category.rb b/app/models/category.rb index 76a83866..4837c9cf 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -5,7 +5,7 @@ class Category < ApplicationRecord belongs_to :family has_many :budget_categories, dependent: :destroy - has_many :subcategories, class_name: "Category", foreign_key: :parent_id + has_many :subcategories, class_name: "Category", foreign_key: :parent_id, dependent: :nullify belongs_to :parent, class_name: "Category", optional: true validates :name, :color, :family, presence: true