5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 09:31:43 +00:00

no perder el nombre del thumbnail

This commit is contained in:
f 2018-10-02 17:11:13 -03:00
parent 8718d1ef96
commit f72f1670d9
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7

View file

@ -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