title: Carrierwave empty files - The file “MyDocument.pdf” could not be opened because it is empty
body: <p>I am using Carrierwave to upload files. On my development machine running OS X 10.8 I am able to upload the file and download the file as expected. Tailing the development log I see:</p>
  
  <pre><code>Started GET "/resources/download_file/11" for 127.0.0.1 at 2013-03-24 06:29:33 -0400
  Processing by ResourcesController#download_file as HTML
    Parameters: {"id"=&gt;"11"}
    Resource Load (0.2ms)  SELECT "resources".* FROM "resources" WHERE "resources"."id" = ?     LIMIT 1  [["id", "11"]]
  Sent file     /Users/scervera/rails_apps/mdn/public/uploads/resource/document/11/MyDocument.pdf (0.1ms)
  Completed 200 OK in 2ms (ActiveRecord: 0.2ms)
  </code></pre>
  
  <p>After deploying with Capistrano onto my Ubuntu 12.04 server VM, I am able to upload the file (and verify it is physically on the server), however, when I click on the link to download the file I receive a message that says:</p>
  
  <p>"The file “MyDocument.pdf” could not be opened because it is empty."</p>
  
  <p>Tailing the production.log shows this:</p>
  
  <pre><code>Started GET "/resources/download_file/1" for 192.168.0.90 at 2013-03-24 06:31:12 -0400
  Processing by ResourcesController#download_file as HTML
    Parameters: {"id"=&gt;"1"}
  Sent file     /var/mdnapp/releases/20130322184251/public/uploads/resource/document/1/MyDocument.pdf (0.1ms)
  Completed 200 OK in 2ms (ActiveRecord: 0.1ms)
  </code></pre>
  
  <p>Note that this sql line is missing:</p>
  
  <pre><code>Resource Load (0.2ms)  SELECT "resources".* FROM "resources" WHERE "resources"."id" = ? 
  </code></pre>
  
  <p>When I tried to open the file, it is indeed empty. </p>
  
  <p>Also, I have tried adding the following to my deploy.rb, but while this is helpful, did not solve this particular problem:</p>
  
  <pre><code>set :shared_children, shared_children + %w{public/uploads}
  </code></pre>
  
  <p><strong>Additional Details</strong>
  I have a resources_controller with a method called download_file. See below:</p>
  
  <pre><code>def download_file
    @resource = Resource.find(params[:id])
    send_file(@resource.document.path,
          :type =&gt; 'application/pdf',
          :disposition =&gt; 'attachment',
          :url_based_filename =&gt; true)
  end
  </code></pre>
  
  <p>In my view I have a link tag that calls this method. See view code below:</p>
  
  <pre><code>&lt;% if @resources.empty? %&gt;
      &lt;p&gt;There are no resources available at this time.&lt;/p&gt;
  
  &lt;% else %&gt;
      &lt;% @resources.each do |resource| %&gt;
  
      &lt;div class="resource_wrap clearfix"&gt;
              &lt;h1&gt;&lt;%= resource.title.html_safe %&gt;&lt;/h1&gt;&lt;h2&gt;&lt;%= resource.subtitle.html_safe %&gt;&lt;/h2&gt;
          &lt;p&gt;&lt;%= image_tag resource.image_url(:wallet).to_s %&gt;&lt;%= resource.description.html_safe %&gt;&lt;/p&gt;
  
          &lt;div id="attachments"&gt;
              &lt;% if resource.document? %&gt;
                  &lt;p&gt;Get the resource:&lt;%= link_to 'Download File', :action =&gt; 'download_file', :id =&gt; resource.id %&gt;&lt;/p&gt;
              &lt;% end %&gt;
              &lt;% if resource.video? %&gt;
                  &lt;p&gt;Get the video:&lt;%= link_to 'Download Video', :action =&gt; 'download_video', :id =&gt; resource.id %&gt;&lt;/p&gt;
              &lt;% end %&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I'm running rails 3.2.11, ruby 1.9.3p194, carrierwave 0.8.0, rmagick 2.13.2</p>
  
  <p>Please let me know if you need any additional details.</p>