title: How to do a safe join pathname in ruby?
body: <p>My Rails development environment is Windows-based, and my production environment is Linux-based.</p>
  
  <p>It's possible that VirtualHost will be used. Assume that one filename needs to be referenced in the <code>/public</code> folder with <code>File.open('/tmp/abc.txt', 'r')</code>.</p>
  
  <p>—but in Windows it should be <code>C:\tmp\abc.txt</code>. How can I do a correct path join to handle the two different environments?</p>
  
  <pre><code>prefix_tmp_path = '/tmp/'
  filename = "/#{rand(10)}.txt"
  
  fullname = prefix_tmp_path + filename # /tmp//1.txt &lt;- but I don't want a double //
  </code></pre>
  
  <p>And when <code>prefix_tmp_path = "C:\tmp\"</code> I get <code>C:\tmp\/1.txt</code></p>
  
  <p>What is the correct way to handle both cases?</p>