【发布时间】:2016-02-24 01:34:42
【问题描述】:
在为桌面图像附件指定的表单中, 我想从 URL 附加表单中的文件(不添加新字段,想使用上面的附件表单进行附加)。这在 Rails 中首先是可能的吗?这就是我目前所处的位置。
目前,我正在使用 Paperclip 作为图像附件,并且能够通过以下方式获取文件:
image_url = URI.parse('http://www.flicker/image.png')
imageFile = open(URI.parse(image_url))
如果你调用 imageFile,它会输出:#
我已经在我的模型中设置了所有内容:
has_attached_file :image, :styles => { :medium => "300x300#", :thumb => "100x100#" }
validates_attachment_content_type :image, :content_type => /\Aimage/
控制器:
@deal = current_user.deals.build(
#fills out other fields as well but deleted them
#attatch image to field
image: imageFile
)
但不幸的是,简单地为图像分配新操作:成为 imageFile 是行不通的。有什么帮助吗?
【问题讨论】: