我已经在我的Windows 7 64位系统上安装了ImageMagick,并且安装了Paperclip Gem。我的用户模型如下:
class User < ActiveRecord::Base
# Paperclip
has_attached_file :photo,
:styles => {
:thumb=> "100x100#",
:small => "150x150>" }
end
在paperclip.rb和development.rb中,我有以下内容:
Paperclip.options[:command_path] = 'C:/Program Files/ImageMagick-6.6.7-Q16'
我的_form看起来像这样:
<%= form_for(@user, :html => { :multipart => true } ) do |f| %>
<% if @user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :username %><br />
<%= f.text_field :username %>
</div>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :email %><br />
<%= f.text_field :email %>
</div>
<div class="field">
<%= f.label :crypted_password %><br />
<%= f.text_field :crypted_password %>
</div>
<div class="field">
<%= f.label :password_salt %><br />
<%= f.text_field :password_salt %>
</div>
<%= f.file_field :photo%>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
enter code here
我在上传图片时遇到了以下错误:
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: C:/Users/John/AppData/Local/Temp/stream20110212-6576-1us1cdl.png is not recognized by the 'identify' command.>
我能够在命令提示符中使用identify命令,并顺利返回该图像的元数据。请帮忙解决问题,我已经被卡在这个问题上一天了。