I use a carrier to upload images, in my form I added a hidden field for caching, as described in the documentation.
= form_for @user, html: {multipart: true} do |f| %p = f.label :image, "your image" = f.file_field :image, id: "img" = f.hidden_field :image_cache
but the problem is loading the images and saving the records, the tmp directory still has all the temporary / caching files.
is there a way to clear the tmp directory?
I found this post here , but I canโt understand it, and there is no simple explained example.
Edit
I tried to run this command using the console
CarrierWave.clean_cached_files!
it displays me an array of all the files in the tmp directory as follows:
["/home/medBo/projects/my_project/public/uploads/tmp/1380732930-5006-6671","/homโโe/medBo/projects/my_project/public/uploads/tmp/1380754280-4623-3698" ....
but when I go to see what happens, I found that all the files still exist in / tmp (not deleted)
I tried to read more in the link above, I found special considerations about CarrierWave.clean_cached_files! :
Special considerations
This method violates bootloaders that have more than one version. Your first version will be saved, but after that the cleanup code will run and delete the tmp file, which is used to create additional versions. In this case, you better create a rake task that periodically cleans the tmp folders.
What does it mean: "This method violates bootloaders with multiple versions"? (because I use two versions in my loader class of "large and large versions"):
class ImageUploader < CarrierWave::Uploader::Base
I also try to run the task to see if the folders inside tmp / directory will be deleted, but the task does not work:
task :delete_tmp_files do FileUtils.rm_rf Dir.glob("#{Rails.root}/public/uploads/tmp/*") end