Last active
September 11, 2015 08:30
-
-
Save osulyanov/2e2e6cf0b4c1b96c092c to your computer and use it in GitHub Desktop.
Generate random file name and save old saved file names (CarrierWave FTP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def filename | |
if original_filename | |
if model && model.read_attribute(mounted_as).present? | |
model.read_attribute(mounted_as) | |
else | |
"#{SecureRandom.hex}.#{File.extname(file.filename)}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment