I have a project where I import a csv. One of the columns in the CSV is a remote_image_url.
When a user imports the CSV, I want to fetch all the remote images and add them to our project.
In my model I have the following. (view full model on gist)
def self.import(file) CSV.foreach(file.path, headers: true) do |row| Deal.delay.create! row.to_hash end end def image_remote_url=(url_value) self.image = URI.parse(url_value) @image_remote_url = url_value end
If I remove
Deal.create!, it works fine. However when I run it with the delayed_job, it does properly extract the image filename and put it in the correct paperclip column, but it does not actually perform the upload.
I’m confused as to where to add instructions to make this work properly.