一旦您上传了文件,是否可以在保存模型之前打开该文件?在将其保存在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