From ddff6c71d7843cf2eaa1e12003930eb65d27ef20 Mon Sep 17 00:00:00 2001 From: jazzari Date: Thu, 5 Oct 2023 17:13:47 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20corregida=20identaci=C3=B3n=20#13077?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/site.rb | 9 +-------- app/services/site_service.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index a8c5e376..89dd5ca8 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -54,8 +54,7 @@ class Site < ApplicationRecord before_create :clone_skel! # Elimina el directorio al destruir un sitio before_destroy :remove_directories! - # Cambiar el nombre del directorio - before_update :update_name! + before_save :add_private_key_if_missing! # Guardar la configuración si hubo cambios after_save :sync_attributes_with_config! @@ -485,12 +484,6 @@ class Site < ApplicationRecord FileUtils.rm_rf path end - def update_name! - return unless name_changed? - - FileUtils.mv path_was, path - reload_jekyll! - end # Sincroniza algunos atributos del sitio con su configuración y # guarda los cambios diff --git a/app/services/site_service.rb b/app/services/site_service.rb index 7022244c..3a803972 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -87,6 +87,15 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do result.present? end + def rename(name) + Site.transaction do + site.name = name + FileUtils.mv site.path_was, site.path(name: name) + ActiveStorage::Blob.where(service_name: site.name_was).update_all(service_name: site.name) + site.save + end + end + private # Guarda los cambios de la configuración en el repositorio git