首先,如果遇到这个问题,Paperclip::NotIdentifiedByImageMagickError,先检查下环境变量是否配置了ImagicMagick的路径。
cmd下path 查看,首先加入ImageMagick path环境
其次,cmd下运行下面两个命令:
convert logo: logo.gif identify logo.gif
看是否运行成功
如果还没等到解决
has_attached_file :photo, :whiny => false, #加入这个配置,看下是否能等到解决 :styles => { :medium => "300x300>", :thumb => "100x100>" }
可以参考https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip.rb这个链接。
如果问题还是出现的话,在config/initializers目录下增加个文件paperclip.rb
Paperclip.options[:command_path] = "E:\ImageMagick"
Paperclip.options[:swallow_stderr] = false
def run cmd, params = "", expected_outcodes = 0
command = %Q<#{%Q[#{path_for_command(cmd)} #{params}].gsub(/\s+/, " ")}>
command = "#{command} 2>#{bit_bucket}" if Paperclip.options[:swallow_stderr]
output = `#{command}`
unless [expected_outcodes].flatten.include?($?.exitstatus)
raise PaperclipCommandLineError, "Error while running #{cmd}"
end
output
end
特别感谢:https://www.cnblogs.com/lmei/p/3321981.html 以及博主