Skip to content

Instantly share code, notes, and snippets.

@osulyanov
Last active September 11, 2015 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osulyanov/2e2e6cf0b4c1b96c092c to your computer and use it in GitHub Desktop.
Save osulyanov/2e2e6cf0b4c1b96c092c to your computer and use it in GitHub Desktop.
Generate random file name and save old saved file names (CarrierWave FTP)
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