Last Updated: February 25, 2016
·
974
· proxygear

Ruby Tempfile without Postfix

Everething is explained here : http://apidock.com/ruby/v1_9_3_125/Tempfile/new/class

If you create a Tempfile this way :

f = Tempfile.new 'test.png'

You'll get a file name looling like this :

f.path => 'SOMEPATH/test.png20130627-13175-1ejj0w8'

If you don't want the post fix you need to pass an array instead :

f = Tempfile.new['text', '.png'] #don't forget the '.'
f.path
#=> "SOMEPATH/text20130627-13175-1ejj0w8.png"