几天来,我一直在努力解决这个问题。最近,我的图片上传器已停止正常工作。我已经调查了几种可能性,但没有一个建议的解决方案适用于我的情况。
错误信息是:
#<Paperclip::Errors::NotIdentifiedByImageMagickError:Paperclip::Errors::NotIdentifiedByImageMagickError>
以下是详细信息:
- Mac OS X 10.8.3
- ImageMagick 6.8.4-4 2013-03-29
- libtool => /usr/bin/libtool
- 导轨 3.2.13
- 红宝石 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)
模型(我正在更新一个教室对象,但图片位于位置模型中。(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 的命令行工具(有人建议该问题可能与过时的 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"}
上传有效,但我有点需要缩放;-)
谁能看到我缺少的东西?