Search code examples
ruby-on-railspaperclippost-processing

Why isn't paperclip post processing working?


Hello I've been looking around at all the various tutorials out there for Paperclip post processing but somehow I can not get the 'Make' method to invoke.

Take a look at line 36 here... http://pastie.org/private/epfgcxywhyh4wpmozypg

It uploads normally without any errors or warnings but I can never see the puts statement in the make method which tells me that this isn't being invoked.

EDIT

I can run this in the model without a problem and I get True,

def class_exists?(class_name)
   klass = Paperclip.const_get(class_name)
   return klass.is_a?(Class)
rescue NameError
   return false
end

Any ideas?


Solution

  • Two days ago I was facing the same problem. Here what I did to make it work:

    Go to the command prompt and type: "which convert" command. This is ImageMagick command so if it says /usr/bin/convert then try adding

    Paperclip.options[:command_path] = "/usr/bin"
    

    in your config/environments/development.rb. Remove /convert from what you get over there.

    then change name of your file file_contents.rb to paperclip_postprocess.rb and put it into directory: RAILS_ROOT/config/initializers/paperclip_postprocess.rb

    You can cross check if your attachment is being processed or not by adding following lines in your model:

       before_post_process :before_post_process
       after_post_process :after_post_process
    
       def before_post_process
            puts "===========Before processing attachment==========="
       end
    
       def after_post_process
            puts "-----------After processign attachment------------"
       end
    

    Take a look here

    It worked for me at least.