0

Status

I have to download an image from a 3rd-party URL and attach the downloaded file (a picture in my case) as an attachment to a local object. Thus I created a PictureLoader class and written a class method in this class.

I am doing the following:

  1. picture = URI.open(image_url)
  2. object.the_downloaded_picture.attach(io: picture, filename: object.id.to_s+"_picture.jpg", content_type: 'image/jpeg')

The local server console (=> rails s) fails with

ArgumentError (A copy of PictureLoader has been removed from the module tree but is still active!)

GOAL: I am simply trying to download an image an attach it but I dont know how to solve this.

Julian
  • 1
  • 2
  • How do you call this method? How do you define this `PictureLoader`? – mechnicov Oct 05 '22 at 10:21
  • Does this answer your question? [A copy of xxx has been removed from the module tree but is still active](https://stackoverflow.com/questions/29636334/a-copy-of-xxx-has-been-removed-from-the-module-tree-but-is-still-active) – mechnicov Oct 05 '22 at 10:21
  • @mechniov RE "How do you call this method?" what method? RE "How do you define this PictureLoader?" a simple class: require 'httparty' require 'open-uri' class PictureLoader I will look at your posted answer now! – Julian Oct 06 '22 at 08:46

1 Answers1

0

I deactivated caching in the local dev config + used the "down" gem to download the image. Works perfect!

Julian
  • 1
  • 2