From f72f1670d9a77f0807b2560219136bdc3ebbba30 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 2 Oct 2018 17:11:13 -0300 Subject: [PATCH] no perder el nombre del thumbnail --- app/models/post/image_uploader.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/post/image_uploader.rb b/app/models/post/image_uploader.rb index ea16ad0..101b0fe 100644 --- a/app/models/post/image_uploader.rb +++ b/app/models/post/image_uploader.rb @@ -45,8 +45,9 @@ class Post::ImageUploader < CarrierWave::Uploader::Base # XXX los nombres de los archivos siempre son únicos, no chequeamos si # están repetidos. def filename - @unique_filename ||= if /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\..*\Z/ =~ file.try(:filename) - file.try(:filename) + current_filename = parent_version.try(:filename) || file.try(:filename) + @unique_filename ||= if /\A(thumb_)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\..*\Z/ =~ current_filename + current_filename else [SecureRandom.uuid, '.', file.extension].join end