In a form designated for a desktop image attachment,
I want to instead attach a file in the form from a URL(without adding a new field, want to attach using the attachment form above). Is this first and foremost possible within Rails? Here's where I'm at so far.
Currently, I'm using Paperclip for image attachments and am able to get a file by using:
image_url = URI.parse('http://www.flicker/image.png')
imageFile = open(URI.parse(image_url))
And if you were to call the imageFile it would output this: #< File : 0x007fad310ca238>
I've setup everything in my model:
has_attached_file :image, :styles => { :medium => "300x300#", :thumb => "100x100#" }
validates_attachment_content_type :image, :content_type => /\Aimage/
Controller:
@deal = current_user.deals.build(
#fills out other fields as well but deleted them
#attatch image to field
image: imageFile
)
But unfortunately simply assigning in the new action for the image: to be an imageFile doesn't work. Any help?