please suggest me a way save image from url by paperclip. thanks
A:
First download the image with the curb
gem to a TempFile
and then simply assign the tempfile object and save your model.
Ariejan
2010-10-29 08:28:14
+1
A:
Here is a simple way:
require "open-uri"
class User < ActiveRecord::Base
has_attached_file :picture
def picture_from_url(url)
self.picture = open(url)
end
end
Then simply :
user.picture_from_url "http://www.google.com/images/logos/ps_logo2.png"
slainer68
2010-10-29 09:50:37
thank you. it helpful for me.
Nam Khanh
2010-10-29 10:44:54