2

使用回形针 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
4

2 回答 2

1

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

安装后

环境

  1. 打开config/environments/development.rb
  2. 添加以下行:Paperclip.options[:command_path] = 'C:\Program Files (x86)\GnuWin32\bin'
  3. 重启你的 Rails 服务器
于 2015-12-26T00:07:29.063 回答
0

这适用于 Windows 8:

1.下载文件.exe

2.通过运行你的cmd测试是否安装好,并输入以下指令
转换标志:logo.miff然后运行imdisplay logo.miff

您将获得自定义徽标图像,该图像将在您的 Windows 屏幕上弹出。从这里开始,您可以开始在 rails 应用程序上配置所有内容

打开 config/environments/development.rb

添加以下行: Paperclip.options[:command_path] = 'C:\tools\GnuWin32\bin' 如果您的 rails 服务器当前正在运行,请停止服务器,然后再次运行 rails s。之后您应该准备好了。在您的应用上上传图片。

于 2016-04-24T17:21:19.827 回答