ruby-on-rails – Rails3和Paperclip
发布时间:2020-12-17 01:19:18 所属栏目:百科 来源:网络整理
导读:我已将我的应用程序从rails 2.3迁移到rails3,我的回形针有问题. 我看到在paperclip git上有一个rails3的分支. 所以我在Gemfile中添加了“gem’paperclip’,:git =’git://github.com/thoughtbot/paperclip.git’,: branch =’rails3’”并启动命令bundle i
我已将我的应用程序从rails 2.3迁移到rails3,我的回形针有问题.
我看到在paperclip git上有一个rails3的分支. 所以我在Gemfile中添加了“gem’paperclip’,:git =>’git://github.com/thoughtbot/paperclip.git’,: branch =>’rails3’”并启动命令bundle install. 一旦安装了回形针,上传工作正常但不是样式.我看到了修复它的黑客攻击. # 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 我的问题是我收到此错误消息:未初始化的常量Paperclip :: Cropper 有人有想法解决这个问题吗? 有关信息,我的应用程序在rails 2.3.4上正常工作. 解决方法
我也有同样的问题.好像回形针处理器没有加载到rails 3.直到有人修复它,我破解了在/ config / initializers中移动cropper.rb文件的问题
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读