paperclip callbacks or simple processor?
Asked Answered
K

3

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?

Kinghood answered 24/12, 2010 at 20:45 Comment(1)
In which line in paperclip does the error occur?Denning
K
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.

Kinghood answered 26/12, 2010 at 18:21 Comment(0)
E
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.

Expectorate answered 30/10, 2013 at 3:57 Comment(1)
I had the same problem when updating the Paperclip gem. Your fix worked for me. Thank you!Higginson
A
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

Alain answered 25/1, 2016 at 11:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.