Skip to content

Instantly share code, notes, and snippets.

@ZakharDay
Created January 21, 2019 14:43
Show Gist options
  • Save ZakharDay/9fc674498d9a3cbc81a271e0762503f1 to your computer and use it in GitHub Desktop.
Save ZakharDay/9fc674498d9a3cbc81a271e0762503f1 to your computer and use it in GitHub Desktop.
def filename
"#{secure_token}.#{file.extension}" if original_filename.present?
end
private
def secure_token
var = :"@#{mounted_as}_secure_token"
model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.uuid)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment