jnicklas/carrierwave — Issue #629: Again Errno::ENOENT No such file or directory
Author: graffzon
Created: 2012-02-22 11:09:14+00:00
State: open

Hi, I have issue which looks like that:
[#395](https://github.com/jnicklas/carrierwave/issues/395)

Here is log https://gist.github.com/1884114

In development all is ok, but in production when I try to load picutre, which should be somehow processed - app crashes.

Using local storage, tried to remove tmp file clearing. Here is my code:

class BaseUploader CarrierWave::Uploader::Base
include CarrierWave::MiniMagick

storage :file

before :store, :remember_cache_id
after :store, :delete_tmp_dir

def remember_cache_id(new_file)
@cache_id_was = cache_id
end

def delete_tmp_dir(new_file)
if @cache_id_was.present? && @cache_id_was =~ /\A[\d]{8}\-[\d]{4}\-[\d]+\-[\d]{4}\z/
FileUtils.rm_rf(File.join(cache_dir, @cache_id_was))
end
end

def cache_dir
"#{Rails.root}/public/uploads/tmp"
end

def store_dir
"#{Rails.root}/public/uploads/#{Rails.env}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end

app/uploaders/image_big_uploader.rb

class ImageBigUploader BaseUploader

version :thumb, :if => :small_unpresent? do
process :resize_to_fit => [200,200]
end

protected

def small_unpresent? picture
!model.image_small.present?
end
end

config/initializers/carrierwave.rb

if Rails.env.test? or Rails.env.cucumber?
CarrierWave.configure do |config|
config.storage = :file
config.enable_processing = false
config.root = ::Rails.root.to_s + "/public"
end
end

Carrierwave v.0.5.8

Best regards, Kirill.