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