title: Overwrite when uploading files with rails?
body: <p>i upload files in rails with following code:</p>
  
  <pre><code>name = upload['datafile'].original_filename
  directory = "public/data/#{id}/#{app_id}"
  
  Dir.mkdir("#{RAILS_ROOT}/public/data/#{id}/#{app_id}")
  
  path = File.join(directory, name)
  
  File.open(path, "wb") { |f| f.write(upload['datafile'].read) }
  </code></pre>
  
  <p>can someone tell me how i can tell rails, that it should overwrite the file when it already exists?</p>
  
  <p>thanks!</p>