在试图将png
保存到具有附加的paperclip模型时,我遇到了错误。
我的User
模型:
class User < ActieRecord::Base
attr_accessible :icon
has_attached_file :icon, :url => "/system/users/icon/:hash.:extension",
:hash_secret => "superSecretHashSecret",
:styles => { :medium => "300x300>", :thumb => "100x100>" }
end
尝试设置图标的示例:
u = User.last
u.icon = open(Rails.root + "spec/fixtures/files/example.png")
u.save
示例模型错误:
:icon => ["/var/folders/43/810gn/T/example20121104-36855-1v7t136.png is not recognized by the 'identify' command."]
有很多人发布了类似于这个问题的帖子,特别是这个,但是那些解决方案对我都不起作用。
我的command_path已经正确设置:
O:~ $ which identify
/usr/local/bin/identify
在
development.rb
文件中。Paperclip.options[:command_path] = "/usr/local/bin/"
这可能仍然是问题所在。 当尝试直接使用 `identify 时,我会收到以下错误:
O:~ $ identify workspace/app/spec/fixtures/files/example.png
dyld: Library not loaded: /usr/lib/libltdl.7.dylib
Referenced from: /usr/local/bin/identify
Reason: image not found
Trace/BPT trap: 5
有什么建议是关于这里正在发生的事情吗?
我已经尝试重新安装ImageMagick。
brew unlink imagemagick
brew install imagemagick
有人建议添加Rmagick
。它绝对不是使用Paperclip所必需的,也没有帮助。
另一个解决方案是删除:style
属性。但这不是一个解决方案。我需要对图像进行处理。
我在项目中的另一个模型上成功使用了Paperclip,该模型处理的是非图像/不进行任何处理的文档。所以我知道这可能与此有关。
还有其他建议如何解决这个问题吗?