jrgifford / delayed_paperclip

Process your Paperclip attachments in the background with delayed_job or Resque.
http://www.jstorimer.com/ruby/2010/01/30/delayed-paperclip.html
MIT License
402 stars 155 forks source link

Overwriting process_image_url when I have two classes having a delayed attachment #128

Open tnzk opened 9 years ago

tnzk commented 9 years ago

I have two classes both having an attachment to be delayed-processed. One of them have :processing_image_url option specified and another don't, looks like:

class Person < ActiveRecord::Base
  has_attached_file :avatar, PAPERCLIP_STORAGE_OPTS
  process_in_background :avatar, processing_image_url: "in_processing.png"
end

class Organization < ActiveRecord::Base
  has_attached_file :picture, PAPERCLIP_STORAGE_OPTS
  process_in_background :picture
end

In this setting, Person#processing_image_url may return nil. I have tried in rails console and got the result below:

 $ rails c
> person = Person.find 1
> organization = Organization.find 1
> organization.picture.processing_image_url #=> nil
> person.avatar.processing_image_url #=> nil; but I expects this to be "in_processing.png".

This behavior seems to depends on the load order of the classes; when I loaded (instanciated?) Organization first, the instance of Person keeps the option correct.

I suspect this is caused by overwriting paperclip_definitions in DelayedPaperclip::ClassMethodss#process_in_background.

katafrakt commented 9 years ago

Hi! I wasn't able to reproduce this kind of behaviour with:

What was your setup?

ScotterC commented 9 years ago

@katafrakt thanks for your help!

tnzk commented 9 years ago

I encountered the behaviour in setup as follows: