【发布时间】:2015-08-23 12:31:19
【问题描述】:
我正在使用paperclip gem 来处理图像并将其保存在我的Gemfile 中。我也安装了ImageMagick,是我给命令which convert还是which identify,我得到/opt/ImageMagick/bin/回来。
所以在我的development.rb 中我添加了
Paperclip.options[:command_path] = "/opt/ImageMagick/bin/"
我的控制器代码来处理帖子的创建 -
def create
@post = Post.create(post_params)
redirect_to posts_path
end
private
def post_params
params.require(:post).permit(:image, :caption)
end
Post 的型号
class Post < ActiveRecord::Base
validates :image, presence: true
has_attached_file :image, styles: { :medium => "640x" }
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
end
虽然当我从视图页面点击提交时,我收到错误 -
Paperclip::Error in PostsController#create
There was an error processing the thumbnail for
终端输出 -
Processing by PostsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"eBXNVsIDE9vuiHgesSPm+mcWiNMz9s0Vgot27HKZl8uK+UUF5P6YnL47SW65Z0taX1GtGPYzceN+HvDseVA/Ow==", "post"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x007f810f984508 @tempfile=#<Tempfile:/var/folders/nq/mk1lf5tj5_z4n9tyg0wtkmy80000gq/T/RackMultipart20150823-28735-1t6e63j.jpg>, @original_filename="IndiaEpic.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"post[image]\"; filename=\"IndiaEpic.jpg\"\r\nContent-Type: image/jpeg\r\n">, "caption"=>"india"}, "commit"=>"Create Post"}
Command :: PATH=/opt/ImageMagick/bin/:$PATH; file -b --mime '/var/folders/nq/mk1lf5tj5_z4n9tyg0wtkmy80000gq/T/2e0348f0f5226c94029d825fc44da2cd20150823-28735-1vy891l.jpg'
Command :: PATH=/opt/ImageMagick/bin/:$PATH; identify -format '%wx%h,%[exif:orientation]' '/var/folders/nq/mk1lf5tj5_z4n9tyg0wtkmy80000gq/T/2e0348f0f5226c94029d825fc44da2cd20150823-28735-1exazk5.jpg[0]' 2>/dev/null
Command :: PATH=/opt/ImageMagick/bin/:$PATH; identify -format %m '/var/folders/nq/mk1lf5tj5_z4n9tyg0wtkmy80000gq/T/2e0348f0f5226c94029d825fc44da2cd20150823-28735-1exazk5.jpg[0]'
Command :: PATH=/opt/ImageMagick/bin/:$PATH; convert '/var/folders/nq/mk1lf5tj5_z4n9tyg0wtkmy80000gq/T/2e0348f0f5226c94029d825fc44da2cd20150823-28735-1exazk5.jpg[0]' -auto-orient -resize "640x640" '/var/folders/nq/mk1lf5tj5_z4n9tyg0wtkmy80000gq/T/18ed538b6a2c563c650b284627c4609d20150823-28735-modfab'
不胜感激帮助解决此错误。让我知道是否需要添加更多详细信息。
【问题讨论】:
-
您能否发布您的模型代码文件以帮助进一步解决此问题?