21

I wanted to run the callback after_post_process but it doesn't seem to work in Rails 3.0.1 using Paperclip 2.3.8. It gives an error:

undefined method `_post_process_callbacks' for #<Class:0x102d55ea0>

I want to call the Panda API after the file has been uploaded. I would have created my own processor for this, but as Panda handles the processing, and it can upload the files as well, and queue itself for an undetermined duration I thought a callback would do fine. But the callbacks don't seem to work in Rails3.

after_post_process :panda_create

    def panda_create
      video = Panda::Video.create(:source_url => mp3.url.gsub(/[?]\d*/,''), :profiles => "f4475446032025d7216226ad8987f8e9", :path_format => "blah/1234")
    end

I tried require and include for paperclip in my model but it didn't seem to matter.

Anyideas?

1
  • In which line in paperclip does the error occur?
    – Zabba
    Dec 24, 2010 at 22:37

3 Answers 3

47

Solution...

I put the callback after the paperclip has_attached in the given model and it works beautifully. I was just so used to always putting the callback at the top of all models that this didn't occur to me til later.

0
9

Moving the has_attached_file attribute above the validates_presence_of and validates_attachment in your model still needs to be done it seems. I just ran into the same problem in my Rails 4/Ruby 2 implementation of PaperClip and putting it above fixed it.

1
  • I had the same problem when updating the Paperclip gem. Your fix worked for me. Thank you!
    – Dawn Green
    Jan 15, 2015 at 18:40
1

I ran into this problem because the name of my paperclip image property did not match the name I was validating against.

as_attached_file :image validates_attachment_content_type: :not_image

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.