I'm trying to debug/diagnose some strange behaviour, and hoping someone can have some insight for me. This is in Ruby 1.9.3.
We've got some code that opens an uploaded file to determine its MIME type, which boils down to:
open(file) { |f| get_mime_type(f) }
Pretty straightforward. In this case, file is actually a File object (or a Rack::Test::UploadedFile in our test suite), not a path, but open
seems to work fine with a file object.
... Except that we now have a new member of the team and it's not working for him. His environment is set up for the most part the same way (anything relevant I could think of is identical - ruby version and patchlevel, rails version, installed gems), but on his machine, when a file object is passed to open
, it returns a file object and ignores the block altogether. Passing in a path instead of a file object, however, works:
open(file.path) { |f| get_mime_type(f) }
So that's our temporary fix, but what I'm trying to figure out is why this is happening? I'd appreciate any insight!