FIX: Delete associated channel upon category deletion

Currently when a category is deleted, if it has an associated chat
channel, the latter won’t be deleted automatically.

The fix is quite simple as we were simply missing a `dependent:
:destroy` option on the existing relation.
This commit is contained in:
Loïc Guitaut
2022-11-17 15:16:14 +01:00
committed by Loïc Guitaut
parent e9863b145c
commit 01392ab90c
5 changed files with 22 additions and 5 deletions

View File

@ -5,7 +5,7 @@ module Chat::CategoryExtension
include Chatable
prepended { has_one :category_channel, as: :chatable }
prepended { has_one :category_channel, as: :chatable, dependent: :destroy }
def cannot_delete_reason
return I18n.t("category.cannot_delete.has_chat_channels") if category_channel