Ruby on rails: Paperclip & Ruby Mp3Info

ruby, ruby-on-rails

Solution

try the "path" method instead of "url"

@song.music.path

Problem

I'm trying to upload an MP3 file (using the paperclip plugin) and then read the MP3 info (using the Mp3Info gem) right away so I can get the title, song length etc. I can successfully upload a MP3 file using paperclip, but when I try Mp3Info.open(@song.music.url), I get an error saying the file is empty. Is there a proper reference to a file so that the Mp3Info can find the file? (Note the actual file sits in /public/system/musics/:id/original/:filename.extention) ``` ActionView::TemplateError (empty file) on line #5 of app/views/songs/_upload.erb: 5: <% Mp3Info.open( @song.music.url ) do |mp3| %> 6: <% mp3.tag.title %> 7: <% end %> ```

Original source