jstorimer/delayed_paperclip

after_post_process callbacks not working ?

rnaud opened this issue · 8 comments

While using DJ paperclip, my callbacks are not working,
My callbacks :
#after_file_post_process :add_notification
#after_post_process :add_notification

They are working when I use after_create, but I need the after post process to send a mail using the thumbnail version of the attachement.

Am I doing something wrong ?

Hi,

What case do you mean exactly?

  • The callback is not called during the "front end" process, but later during the DJ process.
  • The callback is never called, not even during the DJ process.

From my experience the callback are never called.

The correct behavior would be that it they are called during the DJ process.

Alright, here I come again.
Callbacks work, you just need to be sure that the
after_post_process in placed before the process_in_background definition.

However, and this is a big issue. The after_post_process callback is still called before the after save, so the url of the picture is not accessible. So if I want to send a mail with the photo or post a link to facebook with the embeded picture, this is not doable.

How would you go around that issue ? What other callback can I use ?

The problem lays with the method url_with_processed. This method will use the default_url options as long as the processing hasn't happend.

When joining this project this functionality was present and I kept it during the rewrite.

However, at my job where we are using this feature, we disagreed with the reasoning behind this method. We believe that when the file exists, its URL should also exist. It's the controller's job to handle the "not jet processed" case.
We removed the method and are using the original url method provided by paperclip.

In your case there are a few things you could do.

  • In the mail use the url_without_processed method
  • remove the url_with_processed method and restore the original url method

If you'd like to see this url behaviour change, please let me know. Or should we make it a configurable option?

Wow I didn't know about the url_without_processed method, that is great, I'll try that right away.

Hi,

I was wondering if this solved your issue. If so, the latest git/HEAD version now has ":url_with_processing => false" which will not modify the URL while processing.

I'm closing this as there has been no response in almost 2 months.

@rnaud I haven't had any success with the solution you mentioned before. My after_attachment_post_process hooks are still not calling. I've also tried the fix mentioned by @Bertg by changing the options inside of delayed_paperclip.

Could you elaborate on your solution to get callbacks working?

EDIT

my current apprach has been to create a config/initializers/delayed_paperclip.rb file with the following contents:

DelayedPaperclip.options[:url_without_processed] = false

But it only seems to be executing the after_attachment_post_process callback, while the rails family of callbacks appears to be running outside of Delayed Job workers. I suspect this is expected functionality. My next step is to try and process the entire model as a Delayed Job.