在rails 3升级后重新定位时出现回形针错误

我有回形针工作上传和保存图像的不同样式但是当我使用来自railscasts教程的jcrop来裁剪图像时它不会裁剪图像。 我收到这个错误

[paperclip] identify -format %wx%h '/var/folders/z+/z+KzOZBFE9irCpbMKKBGFk+++TI/-Tmp-/paperclip-reprocess20110118-19757-1wtrjaj-0[0]' 2>/dev/null [paperclip] convert '/var/folders/z+/z+KzOZBFE9irCpbMKKBGFk+++TI/-Tmp-/paperclip-reprocess20110118-19757-1wtrjaj-0[0]' -crop 28x32+13+15-resize "400x400>" '/var/folders/z+/z+KzOZBFE9irCpbMKKBGFk+++TI/-Tmp-/paperclip-reprocess20110118-19757-1wtrjaj-020110118-19757-1a5n558-0.jpg' 2>/dev/null [paperclip] An error was received while processing: # 

这是在rails 2.3.9中工作,但是hvae刚刚升级到rails 3.0.3我已经获得了所有最新的gem等。

cropper.rb文件如下所示,位于初始化程序目录中

 module Paperclip class Cropper < Thumbnail def transformation_command if crop_command crop_command + super.join(" ").sub(/ -crop \S+/, '') 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 

尺寸正在进入这个但实际上没有裁剪图像。

请任何人都可以帮忙吗?

非常感谢Richard Moss

这是我的工作文件:

 module Paperclip class Cropper < Thumbnail def transformation_command if crop_command crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ') # super returns an array like this: ["-resize", "100x", "-crop", "100x100+0+0", "+repage"] else super end end def crop_command target = @attachment.instance if target.cropping? ["-crop", "#{target.crop_w}x#{target.crop_h}+#{target.crop_x}+#{target.crop_y}"] end end end end 

就像接受回答的补遗一样(假设您正在关注Ryan Bates的Railscast),您需要从模型中删除以下行:

 after_update :reprocess_avatar, :if => :cropping? def reprocess_avatar avatar.reprocess! end 

这将导致无限循环。 然后,您只需要通过添加以下内容将逻辑移动到控制器中的更新操作:

 if @user.cropping? @user.avatar.reprocess! end 

我被挂了一段时间,所以想我会分享。