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"
Written by Benoit Molenda
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#