3
我正在使用https://github.com/jnicklas/carrierwave與AWS3上傳我的應用程序文件到亞馬遜。我有與具有安裝到它的上傳的圖像列(認爲它作爲員工資料圖片)僱員型號:刪除Carrierwave以前上傳的文件混淆了新的文件處理
class Employee < ActiveRecord::Base
mount_uploader :image, ProfileImageUploader
...
end
每當僱員更新其個人資料圖片,我想以前的一個被刪除。爲了做到這一點,我有以下幾點:我的員工模型中的after_update回調:
class Employee < ActiveRecord::Base
...
after_update :remove_changed_image, :if => 'self.image_changed?'
def remove_changed_image
self.image_was.remove!
end
end
這成功刪除了以前的文件。但我也在處理上傳的圖片。在我的Uploder我有以下內容:
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
問題是新文件根本沒有被處理。只有一個版本,未經處理的版本上傳,而如果我不刪除以前的圖像,那麼所有的版本都應該(上傳許多版本)。
任何幫助?謝謝!