use Dir.tmpdir with File.join to create a platform-independent way of creating a temporary file:
require 'tmpdir'
tempfilename = File.join(Dir.tmpdir, "myapp.dat")
tempfile = File.new(tempfilename, "w")
tempfile.puts "This is only temporary"
tempfile.close
File.delete(tempfilename)
Related examples in the same category