Deleting a previously uploaded Carrierwave file causes new files to be processed
I am using https://github.com/jnicklas/carrierwave with AWS3 to upload my app file to Amazon. I have an Employee model with an image column (think of it as an employee profile picture) that has a loader installed:
class Employee < ActiveRecord::Base
mount_uploader :image, ProfileImageUploader
...
end
When an employee updates their profile picture, I want the previous one to be deleted. For this, I have the following after_update callback in my Employee model:
class Employee < ActiveRecord::Base
...
after_update :remove_changed_image, :if => 'self.image_changed?'
def remove_changed_image
self.image_was.remove!
end
end
This successfully deletes the previous file. But I also process the photos that are uploaded. In my Sealer, I have the following:
class ProfileImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_limit => [300, 300]
end
...
end
The problem is that new files are not processed at all. Only one version, unprocessed, is loaded, and if I don't delete the previous image, then everything works as it should (many versions are loaded).
Any help? Thank!
+3
source to share