lulalala lulalala - 1 year ago 143
Ruby Question

Carrierwave temp directory set to uploads/tmp folder

I started using Carrierwave, and I found out that it stores temporary files at multiple places depending on whether it is testing or delayed job.

If it is done during testing(rspec), the temp files will be at


If it is done during delayed job, the temp files will be at

First, I was thinking that
would be a more sensible place, or even the system temporary folder.

Second, the testing being different to normal run seems like a bug.

Is there a way to fix this (either by configuration or monkey patching)? And can I put things in the RAILS_ROOT/tmp folder?

Answer Source

There is config.cache_dir option you can set in 'config/initializers/carrierwave.rb'. But it is relative to '/public'. Looks like you should do that in your uploaders:

class MyUploader < CarrierWave::Uploader::Base

  def cache_dir
    # should return path to cache dir
    Rails.root.join 'tmp/uploads'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download