Question re: Paperclip + Delayed_job


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

  def image_remote_url=(url_value)
    self.image = URI.parse(url_value)
    @image_remote_url = url_value

If I remove delay from 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.

bump please

I’ve just built a quick Rails app to try to duplicate your problem, but everything worked fine for me (here’s my minimal model). I was using Paperclip 3.4.2 with the default filesystem storage backend and Delayed::Job 3.0.5.

What Paperclip storage backend are you using?

Also, have you tried running an isolated test that only sets an image_remote_url and does nothing else? Something like this:

rails runner 'Deal.delay.create! image_remote_url: ""'
rake jobs:workoff
1 Like

Thanks for the reply George! Sorry I didn’t get a notification, didn’t realize you replied.

Miraculously, when I tried this again, it worked. I’m not sure what was causing my problem but the code I shared seems to work fine now.

Thanks again for the assist.