I\'m looking to save a file (in this case an image) located on another http web server using rails 5.2 active storage.
I have an object with a string parameter for s
Just found the answer to my own question. My first instinct was pretty close...
require 'open-uri'
class User < ApplicationRecord
has_one_attached :avatar
before_save :grab_image
def grab_image
downloaded_image = open("http://www.example.com/image.jpg")
self.avatar.attach(io: downloaded_image , filename: "foo.jpg")
end
end