我已经将我的应用程序从rails 2.3迁移到rails3,并且我有回形针问题。 我看到了paperclip git上的rails3分支。因此,我在Gemfile中添加了“gem'paperclip',::git =>'git://github.com/thoughtbot/paperclip.git',:branch =>'rails3'”并启动命令包install 。Rails3和Paperclip
一旦回形针安装,上传工作正常,但不是样式。我看到了一个修复它的黑客。
# in lib/paperclip/attachment.rb at line 293
def callback which #:nodoc:
# replace this line...
# instance.run_callbacks(which, @queued_for_write){|result,obj| result == false }
# with this:
instance.run_callbacks(which, @queued_for_write)
end
之后的样式可以,但我无法激活处理器。我的代码是:
has_attached_file :image,
:default_url => "/images/nopicture.jpg",
:styles => { :large => "800x600>",
:cropped => Proc.new { |instance| "#{instance.width}x#{instance.height}>" },
:crop => "300x300>" },
:processors => [:cropper]
我处理器位于RAILS_APP/lib目录/ paperclip_processors/cropper.rb,包含:
module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command and !skip_crop?
crop_command + super.sub(/ -crop \S+/, '')
else
super
end
end
def crop_command
target = @attachment.instance
trans = "";
trans << " -crop #{target.crop_w}x#{target.crop_h}+#{target.crop_x}+#{target.crop_y}" if target.cropping?
trans << " -resize \"#{target.width}x#{target.height}\""
trans
end
def skip_crop?
["800x600>", "300x300>"].include?(@target_geometry.to_s)
end
end
end
我的问题是,我得到这个错误信息:未初始化不断回形针::裁剪器 裁剪后的处理器未加载。
有人有想法解决这个问题吗?
有关信息,我的应用程序在rails 2.3.4上正常工作。
我最后ly解决了问题,就像你做的一样,除了我把回形针作为插件安装... 有点不那么丑陋:P – Arkan 2010-05-17 17:18:20