views:

119

answers:

1

I upload/save mp3 files through Paperclip, it transforms the name with underscores when it saves it.

For example if I upload "Gould Stokowski 1.mp3" it saves into the the db as "Gould_Stokowski_1.mp3". How can I take out the underscores (replace them with spaces" when I retrieve the file and I want to display the name.

A: 

What does the program do with the characters that started out as underscores? If it does nothing, then there is no way to go back using just the file name. The names don't "round trip."

If you're not concerned with that, then your question really has nothing to do with Paperclip or MP3 files at all. You just need to know how to change all the underscores into spaces. You can use String#tr for that:

$ irb
>> "Gould_Stokowski_1.mp3".tr('_', ' ')
=> "Gould Stokowski 1.mp3"
Rob Kennedy
Ah! Sorry, any suggestion on how to remove the extension at the same time.
rordude
http://stackoverflow.com/questions/1204617/removing-extensions-in-subdirectories
Rob Kennedy