Skip to content

Instantly share code, notes, and snippets.

@phlipper
Created March 13, 2011 03:49
Show Gist options
  • Save phlipper/867845 to your computer and use it in GitHub Desktop.
Save phlipper/867845 to your computer and use it in GitHub Desktop.
normalize filenames for use with s3 authenticated urls
Paperclip.interpolates :normalized_basename do |attachment, style|
filename = attachment.instance.data_file_name
basename = File.basename(filename, File.extname(filename))
basename.gsub(/[^\w\d_-]/i, " ").gsub(/\s+/, "-")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment