图像的内容不是报告的内容

时间:2015-12-16 13:49:49

标签: ruby-on-rails-4 paperclip paperclip-validation

使用回形针GEM时出现以下错误。我尝试上传JPG / PNG并且都无效。好像我得到了验证错误。任何帮助都会非常棒!谢谢!

Image has contents that are not what they are reported to be

class Listing < ActiveRecord::Base
     has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "404.jpg"
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
end

2 个答案:

答案 0 :(得分:1)

如果您正在使用Windows 7开发模式。你需要手动安装file.exe并设置路径。请按照链接中的内容进行操作 installing file.exe manually

安装后

环境

  1. 打开config/environments/development.rb
  2. 添加以下行:Paperclip.options[:command_path] = 'C:\Program Files (x86)\GnuWin32\bin'
  3. 重新启动Rails服务器

答案 1 :(得分:0)

适用于Windows 8:

1.下载file.exe

2.通过运行cmd安装好并按照以下说明进行测试 转换徽标:logo.miff 然后运行 imdisplay logo.miff

您将获得自定义徽标图片,该图片会弹出Windows屏幕。 从现在开始,您可以开始在rails app上配置所有内容

打开config / environments / development.rb

添加以下行:Paperclip.options [:command_path] =&#39; C:\ tools \ GnuWin32 \ bin&#39; 如果您的rails服务器当前正在运行,请制动服务器,然后再次运行rails s。之后您应该准备好了。在您的应用程序上加载图像。