Created
November 30, 2015 11:51
-
-
Save vu2/0b6c99c8033bc0a8f907 to your computer and use it in GitHub Desktop.
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
class PhotoUploader < CarrierWave::Uploader::Base | |
def filename | |
"#{secure_token}.#{file.extension}" if original_filename.present? | |
end | |
protected | |
def secure_token | |
var = :"@#{mounted_as}_secure_token" | |
model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.uuid) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment