From 685845a558a5f9ba0ecbee9eee84cc63393cdc51 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 26 Oct 2023 16:36:29 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20la=20relaci=C3=B3n=20de=20traducci=C3=B3?= =?UTF-8?q?n=20es=20como=20habtm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/post_service.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/services/post_service.rb b/app/services/post_service.rb index 3e77896c..4b7c2d7d 100644 --- a/app/services/post_service.rb +++ b/app/services/post_service.rb @@ -181,7 +181,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do value = metadata.value.dup case metadata.type - when 'has_and_belongs_to_many' + when 'has_and_belongs_to_many', 'locales' associated_posts(value_was - value).each do |remove_post| remove_relation_from(remove_post[inverse_attribute], post.uuid.value) end @@ -211,7 +211,6 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do associated_posts(value).each do |add_post| add_relation_to(add_post[inverse_attribute], post.uuid.value) end - when 'locales' end end @@ -223,6 +222,9 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do end # @todo por qué no podemos usar nil para deshabilitar un valor? + # @param :metadata [MetadataTemplate] + # @param :value [String] + # @return [nil] def remove_relation_from(metadata, value) case metadata.value when Array then metadata.value.delete(value) @@ -234,6 +236,9 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do end # @todo El validador ya debería eliminar valores duplicados + # @param :metadata [MetadataTemplate] + # @param :value [String] + # @return [nil] def add_relation_to(metadata, value) case metadata.value when Array