title: How to use paperclip with a file already on my server?
body: <p>For the record, I'm working on legacy code and I'm trying to plug a new feature without breaking everything. Right now I have a bunch of files on my server as such:</p>
  
  <pre><code> myapp/public/temp/myfile.doc
  </code></pre>
  
  <p>The thing is that I want to create a Docfile object from these files in a controller action.</p>
  
  <p>Here is the trimmed down Docfile class:</p>
  
  <pre><code>class DocFile &lt; ActiveRecord::Base
    has_attached_file :docs,
      :path =&gt; "#{Constants::DOCFILES_PATH}:basename.:extension",
      :url =&gt; "http://#{Constants::SITE_URL}/docs/:basename.:extension"
  end
  </code></pre>
  
  <p>Paperclip has some nice documentation if you upload from a form, but not in my situation.</p>
  
  <p>So how can I "simulate" the fact that I'm uploading a file?</p>
  
  <p>So far I've tried this:</p>
  
  <pre><code>temp_file_url = "correct_rails_root/myapp/public/temp/myfile.doc"
  @docfile = DocFile.new :docs =&gt; temp_file
  </code></pre>
  
  <p>But it's not working.</p>
  
  <p>Any pointers would be appreciated!</p>
  
  <p>Edit:</p>
  
  <p>I did this:</p>
  
  <pre><code>temp_file_url = Constants::TEMPORARY_UPLOAD_PATH + "/" + params[:temp_file_upload][:doc]
  temp_file = File.new(temp_file_url,  "w+")
  @docfile = DocFile.new :docs =&gt; File.open(temp_file_url)
  </code></pre>
  
  <p>It's still not working</p>