一旦您上傳了文件,是否可以在保存模型之前打開該文件?在將其保存在Rails模型中之前打開臨時文件
我正在使用Paperclip將文件保存在/ public文件夾中。
class Book < ActiveRecord::Base
before_save :open_it
has_attached_file :upload
def open_it
a_file = open(upload.url) # this doesn't work before save ?
# ...
end
end
Carrierwave可以,相信回形針也可以.. – MikDiet 2013-05-04 00:39:42
@MikDiet我實際上結束了使用CarrierWave,我有更好的體驗:) – 2013-08-18 02:14:18