From c0ed53b810351b61db543701c4938d41723a6e4e Mon Sep 17 00:00:00 2001 From: ThibG Date: Wed, 18 Dec 2019 16:56:59 +0100 Subject: [PATCH] Fix custom emoji category creation silently erroring out on duplicate category (#12647) Instead, just re-use the existing category if any. Fixes #12608 --- app/models/form/custom_emoji_batch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/form/custom_emoji_batch.rb b/app/models/form/custom_emoji_batch.rb index 076e8c9e3..6b7ea5355 100644 --- a/app/models/form/custom_emoji_batch.rb +++ b/app/models/form/custom_emoji_batch.rb @@ -40,7 +40,7 @@ class Form::CustomEmojiBatch if category_id.present? CustomEmojiCategory.find(category_id) elsif category_name.present? - CustomEmojiCategory.create!(name: category_name) + CustomEmojiCategory.find_or_create_by!(name: category_name) end end