Reputation: 2727
For my application I need a cropping functionality for images. I followed the railscast http://railscasts.com/episodes/182-cropping-images
Aaaall works fine on my local machine. I have my owm paperclip processor, which extends from the Thumbnail processor. This processor is stored under lib/paperclip_processors/cropper.rb
module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command
cmd = crop_command + super.join(" ").sub(/ -crop \S+/, '')
cmd.split(" ")
else
super
end
end
def crop_command
target = @attachment.instance
if target.cropping?
" -crop \"#{target.crop_w.to_i}x#{target.crop_h.to_i}+#{target.crop_x.to_i}+#{target.crop_y.to_i}\" "
end
end
end
end
On my local machine it uses this processor for cropping. On heroku it seems that this module is completely ignored.
Yes, I searched around 6 hours for the solution...
1.
#application.rb
config.autoload_paths += %w(#{config.root}/lib)
#or
config.autoload_paths += Dir["#{config.root}/lib/**/"]
#or
config.autoload_paths += Dir["#{config.root}/lib/paperclip_processors/cropper.rb"]
#all not working
2.
#initializers/includes.rb
require "cropper"
#or
Dir[Rails.root + 'lib/**/*.rb'].each do |file|
require file
end
Why the hell is my module not loading??
Upvotes: 0
Views: 292
Reputation: 2572
You might want to check if the condition is getting invoked.
if target.cropping?
" -crop \"#{target.crop_w.to_i}x#{target.crop_h.to_i}+#{target.crop_x.to_i}+ #{target.crop_y.to_i}\" "
end
I had a similar trouble a few days back with cropping on heroku.
Upvotes: 1