Not really. For the question itself, see this:
ObjectSpace.undefine_finalizer(tmpfile)
The Tempfile library uses Ruby ObjectSpace finalizers to automatically delete itself on garbage collection. By using the above line you can remove the Tempfile's ability to delete itself if you don't delete it. So, for example:
$ irb
2.0.0p0 :001 > require "tempfile"
=> true
2.0.0p0 :002 > t = Tempfile.new("test")
=> #<Tempfile:/tmp/test20140122-6655-80p4b7>
2.0.0p0 :003 > t.write("Hi!")
=> 3
2.0.0p0 :004 > ObjectSpace.undefine_finalizer(t)
=> #<Tempfile:/tmp/test20140122-6655-80p4b7>
2.0.0p0 :005 > exit
$ cat /tmp/test20140122-6655-80p4b7
Hi!
$
There's something else to be aware of though. Tempfile will use system temporary file directories like /tmp
that the OS automatically cleans out every once in a while (for example on every boot). Because of this, even if you "persist" the file, you either need to be OK with it disappearing, or move it to a directory that doesn't get cleaned out by default, like /var/tmp
(the Linux directory for persistant temporary files).
As for your second question, try this code from here:
Dir::Tmpname.create('your_application_prefix') { |path| puts path }
It requires a require "tmpdir"
.