Extract filename obfuscation into module

This commit is contained in:
Alyssa Ross
2016-11-23 23:31:38 +00:00
committed by Andrea Faulds
parent 7161f91313
commit cefef2c571
3 changed files with 25 additions and 16 deletions

View File

@ -0,0 +1,16 @@
module ObfuscateFilename
extend ActiveSupport::Concern
class_methods do
def obfuscate_filename(*args)
before_action { obfuscate_filename(*args) }
end
end
def obfuscate_filename(path)
file = params.dig(*path)
return if file.nil?
file.original_filename = "media" + File.extname(file.original_filename)
end
end