I want to attach an image to a record in the rake task. The only thing I have for image is the URL. This is the URL for the image https://cdn.iconscout.com/icon/free/png-256/google-analytics-7-722699.png.
I used this approach from a StackOverflow answer.
require 'open-uri'
downloaded_file = open(tool.image)
new_tool.image.attach(io: downloaded_file, filename: "foo.png")
This gives the following error.
ActiveStorage::IntegrityError: Unsupported source URL: #<StringIO:0x00007f9bd9759f28>
Caused by:
CloudinaryException: Unsupported source URL: #<StringIO:0x00007f9bd9759f28>
Could someone help me out?