我已经苦恼了几天,我的图像上传器最近停止正常工作。我已经调查了几个可能性,但是没有一种建议的解决方案适用于我的情况。
错误信息为:
#<Paperclip::Errors::NotIdentifiedByImageMagickError:Paperclip::Errors::NotIdentifiedByImageMagickError>
以下是详细信息:
- Mac OS X 10.8.3
- ImageMagick 6.8.4-4 2013-03-29
- libtool => /usr/bin/libtool
- Rails 3.2.13
- Ruby 1.9.3p194
development.rb
包含适当的路径(我已经验证它是否正确使用了which identify
)
Paperclip.options[:command_path] = "/usr/local/bin/"
Gemfile.lock
(相关部分)
paperclip (3.4.1)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.0)
MODEL(我正在更新一个教室对象,但图片驻留在位置模型中。(Classroom has_one :location, :as => :locatable)
模型 location.rb
class Location < ActiveRecord::Base
## Paperclip method for uploading location images
has_attached_file :picture, :styles => {:show => "1200x500#", :medium => "300x300#", :thumb => "100x100>"}, :convert_options => {:show => "-gravity center"}
has_attached_file :building_sign, :styles => { :show => ["1200x500#", :jpg], :medium => ["300x300#", :jpg], :thumb => ["100x100#", :jpg] }, :convert_options => {:show => "-gravity center"}
belongs_to :locatable, :polymorphic => true
belongs_to :location_type
validates :name, :presence => true
validates :latitude, :presence => true,
:length => {:within => 9..18},
:numericality => true
validates :longitude, :presence => true,
:length => {:within => 9..18},
:numericality => true
end
控制器 classrooms_controller.rb
def update
@classroom = Classroom.find_by_facility_code_heprod(params[:id].upcase)
respond_to do |format|
if @classroom.update_attributes(params[:classroom])
format.html { redirect_to(@classroom, :notice => 'Classroom was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @classroom.errors, :status => :unprocessable_entity }
end
end
end
我尝试过以下方法:
- 确保图像名称简单(USB2230.jpg),没有冒号。
- 更新了最新版本的ImageMagick。
- 重新下载并安装了适用于10.8.3的CommandLine工具(有人建议问题可能与过时的libtool相关)。
- 重启电脑。
我尝试了不同的gem版本,包括
# variation 1 gem 'paperclip', '~> 2.8.0' gem "cocaine", "=0.3.2" # variation 2 gem "paperclip", "~> 3.4.0" gem "cocaine", "= 0.4" # variation 3 (which is what is reflected in the included Gemfile.lock info above). gem "paperclip", "~> 3.4.0"
如果我去掉缩放,
:styles => {:show => "1200x500#", :medium => "300x300#", :thumb => "100x100>"},
:convert_options => {:show => "-gravity center"}
上传功能可用,但我需要进行缩放;-)
有人能看出我漏了什么吗?