From 6edd9e67a2797c652aafa033eb09cf3bfdc0e98c Mon Sep 17 00:00:00 2001 From: f Date: Wed, 17 Feb 2021 18:44:28 -0300 Subject: [PATCH] simplificar MetadataSlug --- app/models/metadata_slug.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/models/metadata_slug.rb b/app/models/metadata_slug.rb index 1f12475..09da23f 100644 --- a/app/models/metadata_slug.rb +++ b/app/models/metadata_slug.rb @@ -25,11 +25,7 @@ require 'jekyll/utils' class MetadataSlug < MetadataTemplate # Trae el slug desde el título si existe o una string al azar def default_value - if title - Jekyll::Utils.slugify(title) - else - SecureRandom.hex - end + title ? Jekyll::Utils.slugify(title) : SecureRandom.uuid end def value @@ -40,6 +36,9 @@ class MetadataSlug < MetadataTemplate # Devuelve el título a menos que sea privado y no esté vacío def title - post.title&.value&.to_s unless post.title.private? && !post.title&.value&.blank? + return if post.title&.private? + return if post.title&.value&.blank? + + post.title&.value&.to_s end end