delayed_paperclip icon indicating copy to clipboard operation
delayed_paperclip copied to clipboard

Overwriting process_image_url when I have two classes having a delayed attachment

Open tnzk opened this issue 10 years ago • 3 comments

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.

tnzk avatar Jan 23 '15 15:01 tnzk

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

  • paperclip 4.2.1
  • delayed_paperclip 2.9.0
  • rails 4.2.0.rc3
  • ruby 2.1.5

What was your setup?

katafrakt avatar Feb 08 '15 18:02 katafrakt

@katafrakt thanks for your help!

ScotterC avatar Feb 08 '15 21:02 ScotterC

I encountered the behaviour in setup as follows:

  • paperclip 4.1.1
  • delayed_paperclip 2.9.0
  • rails 4.0.0
  • ruby 2.0.0p598

tnzk avatar Feb 09 '15 04:02 tnzk