title: Rails how to delete a file without failing on error
body: <p>I'm using JPEGCAM to allow users to take a profile pic with their web cam. This uploads a temporary file as so:</p>
  
  <pre><code>def ajax_photo_upload    
    File.open(upload_path, 'w:ASCII-8BIT') do |f|
      f.write request.raw_post
    end
    # @user.photo = File.open(upload_path)
    @user.assign_attributes(
      :photo =&gt; File.open(upload_path),
      :orig_filename =&gt; "#{current_user.full_name}.jpg"
    )
    if @user.save
    respond_to do |format|
    .....
  private
  
    def upload_path # is used in upload and create
      file_name = session[:session_id].to_s + '.jpg'
      File.join(::Rails.root.to_s, 'public', 'temp', file_name)
    end
  </code></pre>
  
  <p>What's the best way to go about deleting this temporary file safely? Thanks</p>