【问题标题】:Image has contents that are not what they are reported to be图像的内容与报告的内容不同
【发布时间】:2015-12-16 13:49:48
【问题描述】:

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

【问题讨论】:

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


    【解决方案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 服务器

    【讨论】:

      【解决方案2】:

      这适用于 Windows 8:

      1.下载file.exe

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

      您将获得自定义徽标图像,该图像将在您的 Windows 屏幕上弹出。 现在你可以开始在 rails app 上配置一切了

      打开 config/environments/development.rb

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-09-06
        • 2016-10-11
        • 1970-01-01
        • 1970-01-01
        • 2021-11-28
        • 2014-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多