Tempfile can create temporary files for you
require 'tempfile' f = Tempfile.new('myapp') f.puts "Hello" puts f.path f.close