I just started using paperclip and have my own processor. I put the new processor in the right place RAILS_ROOT/lib/paperclip_processorsBut it does not load.
The reason for not loading is that it Rails.rootis zero at the time of loading paperclip. I tested this by adding explicit code topaperclip.rb
puts "What is Rails.root? #{Rails.root} #{Rails.root.nil?}"
if defined?(Rails.root) && Rails.root
Dir.glob(File.join(File.expand_path(Rails.root), "lib", "paperclip_processors", "*.rb")).each do |processor|
require processor
end
end
Will be printed What is Rails.root true. And processors never load.
Is there a fix or work for this? Now, the work around is simply to add a requirement for our processor. but that does not seem right. Here is the work (our processor does tar'ing), in the model that will use the processor, you just need to go to the top:
require "#{Rails.root}/lib/paperclip_processors/tar.rb"
class Ad < ActiveRecord::Base
has_attached_file :adzip,
:styles => { :targzip => {:processors => [:tar], :format => 'tgz'} }
end