Skip to content

Instantly share code, notes, and snippets.

@ZakharDay
Created January 21, 2019 14:44
Show Gist options
  • Save ZakharDay/cbfc4c0ffc183e3d9189eeaba439aa6f to your computer and use it in GitHub Desktop.
Save ZakharDay/cbfc4c0ffc183e3d9189eeaba439aa6f 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