3

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?

animuson
  • 53,861
  • 28
  • 137
  • 147
yekta
  • 3,363
  • 3
  • 35
  • 50
  • 1
    Are you sure the FileContents class is being loaded? – tilleryj Mar 11 '11 at 22:38
  • Thats what I was trying to verify with the puts on line 36, I've also tried adding a debugger (ruby-debug) but it was never invoked hence why I'm wondering why its not being invoked. Is there another way I can verify that the FileContents class is being loaded? – yekta Mar 14 '11 at 13:36
  • Try raising an exception on the first line of the file (raise 'here'). This will at least verify that the file is being loaded, which I think is a good place to start. – tilleryj Mar 14 '11 at 18:14

2 Answers2

4

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.

Surya
  • 15,703
  • 3
  • 51
  • 74
0

I noticed this line in the Paperclip README:

NOTE: Because processors operate by turning the original attachment into the styles, no processors will be run if there are no styles defined.

And looking at your paste, you define everything but a :style argument, so maybe that's the problem?

Robert Speicher
  • 15,382
  • 6
  • 40
  • 45