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