From 67bb6e45df3f0540fb11576f68f41a627b1687ca Mon Sep 17 00:00:00 2001 From: f Date: Thu, 26 Oct 2023 16:31:34 -0300 Subject: [PATCH] refactor: guardar las relaciones luego de actualizarlas --- app/services/post_service.rb | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/app/services/post_service.rb b/app/services/post_service.rb index 83d30a50..3e77896c 100644 --- a/app/services/post_service.rb +++ b/app/services/post_service.rb @@ -22,12 +22,6 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do # Recorrer todas las asociaciones y agregarse donde corresponda update_associations(post) - associated_posts_to_save.each do |associated_post| - next unless associated_post.save(validate: false) - - added_paths << associated_post.path.value - end - commit(action: :created, add: added_paths) end @@ -67,12 +61,6 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do # Recorrer todas las asociaciones y agregarse donde corresponda update_associations(post) - associated_posts_to_save.each do |associated_post| - next unless associated_post.save(validate: false) - - added_paths << associated_post.path.value - end - commit(action: :updated, add: added_paths, rm: rm) end @@ -226,6 +214,12 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do when 'locales' end end + + associated_posts_to_save.each do |associated_post| + next unless associated_post.save(validate: false) + + added_paths << associated_post.path.value + end end # @todo por qué no podemos usar nil para deshabilitar un valor?