Forum: Ruby on Rails Tempfile.new -> result not unique

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Andrea B. (Guest)
on 2007-06-18 20:52
(Received via mailing list)
Hi,

I am using Tempfile to store temporary data on disk.

The documentation I've read (The Ruby Way, p353) states:

"The new method (Tempfile.new("seed_str")) takes a basename as a seed
string, and concatenates onto it the process id and a unique
sequence number."


however, I am testing my web app, and request after request, I end up
with the exact same filename..

I worked around this by actually adding a random number within the
seed string:

rand_str = rand
Tempfile.new(txt#{rand_str})

however, I am sure there must be a way to get Tempfile to work
properly
and return an actual unique name?

thanks for your help,

__
Andrea
This topic is locked and can not be replied to.