Use Paperclips filecleaner to clean the filename before storing in the db.