2010-06-08 41 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