我有一个表单,允许我上传图像。然后在控制器中,我获得上传的图像,并对该图像运行一些进程。图像处理后,我将其存储在/public/文件夹中。
我想把那张照片交给回形针保存。有人能建议我如何实现这一点吗?
谢谢
发布于 2013-09-02 17:06:29
你可以这样做:-我假设这个模型。
class SomeModel < ActiveRecord::Base
has_attached_file :avatar
end在你的控制器中
def someaction
a = SomeModel.new
#you did your processing here and saved it in public folder
# if you have file object, you can use it or
f = File.open((File.join(Rails.root, "public", filename)))
a.avatar = f
a.save
endhttps://stackoverflow.com/questions/18568016
复制相似问题