2010-06-08 39 views
27

我已經隨着時間的推移,改變了類Deal的大拇指尺寸。通過這些更改,用戶正在上傳到網站,所以很少有人擁有不同大小的拇指。我想reprocress或刷新這些,所以我去到我的根和類型:試圖讓回形針刷新或重新加工無法正常工作

rake paperclip:refresh class=Deal 

什麼也沒做拇指大小。然後我在腳本/控制檯:

Deal.find( 987).reprocess!

返回此:

NoMethodError: undefined method `reprocess!' for #<Deal:0xb68a0988> 
from /data/HQ_Channel/releases/20100607130346/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:260:in `method_missing' 
from (irb):7 

我的交易類是這樣的:

=> Deal(id: integer, organization_id: integer, deal: string, value: string, what: string, description: string, image_file_name: string, image_content_type: string, image_file_size: integer, image_updated_at: datetime, created_at: datetime, updated_at: datetime, deal_image_file_name: string, deal_image_content_type: string, deal_image_file_size: integer, deal_image_uploaded_at: datetime) 

我能做些什麼來把它重新處理原有使拇指正確的大小在當前拇指大小參數?

更新:我發現attachment.rb附帶回形針。有趣的是,像.save.updated_at這樣的方法工作。但reprocess!和其他一些方法沒有。有什麼東西聞起來顯然不合適?

回答

64

Got it!

這是因爲回形針不是相對於模型的對象,而是模型的對象的圖像。這麼寫合適的,它的工作是這樣的:

Model.find(#).image.reprocess! 
+17

Model.find_each {|用品| thing.image.reprocess! } – Schneems 2012-07-24 20:39:22