0

我有一个表格可以让我上传图片。然后在控制器中,我获取上传的图像并在图像上运行一些进程。处理完图像后,我将其存储在/public/文件夹中。

我想拍下那张照片,然后把它交给回形针保存。有人可以告诉我如何实现这一目标。

谢谢

4

1 回答 1

0

你可以这样做:- 我假设这个模型。

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
end
于 2013-09-02T09:06:29.323 回答