对于我的应用程序,我需要图像的裁剪功能。我跟着 railscast http://railscasts.com/episodes/182-cropping-images
Aaaall 在我的本地机器上运行良好。我有我的 owm 回形针处理器,它从 Thumbnail 处理器扩展而来。该处理器存储在 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
在我的本地机器上,它使用这个处理器进行裁剪。在 heroku 上,这个模块似乎被完全忽略了。
是的,我搜索了大约 6 个小时的解决方案......
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
为什么我的模块没有加载?