title: Ruby: No such file or directory @ rb_sysopen - testfile (Errno::ENOENT)
body: <p>I want to write something to a file.</p>
  
  <pre><code># where userid is any intger [sic]
  path = Rails.root + "public/system/users/#{user.id}/style/img.jpg" 
  File.open(path, 'wb') do |file|
    file.puts f.read
  end 
  </code></pre>
  
  <p>When this code is executed, I'm getting this error. I know this folder doesn't exist, but <code>File.open</code> with <code>w</code> mode creates a new file if it doesn't exist.</p>
  
  <p>Why is this not working?</p>