delayed_paperclip
delayed_paperclip copied to clipboard
Overwriting process_image_url when I have two classes having a delayed attachment
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.
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 thanks for your help!
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