Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 图像包含的内容与报告的内容不同_Ruby On Rails 4_Paperclip_Paperclip Validation - Fatal编程技术网

Ruby on rails 4 图像包含的内容与报告的内容不同

Ruby on rails 4 图像包含的内容与报告的内容不同,ruby-on-rails-4,paperclip,paperclip-validation,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 => "100x1

我在使用回形针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
图像包含的内容与报告的内容不同
类列表{:medium=>“200x”,:thumb=>“100x100>”},:default\u url=>“404.jpg”
验证\u附件\u内容\u类型:图像,:内容\u类型=>/\Aimage\/.\Z/
结束

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

安装后

环境

  • 打开
    config/environments/development.rb
  • 添加以下行:
    Paperclip.options[:command\u path]=“C:\Program Files(x86)\GnuWin32\bin”
  • 重新启动Rails服务器

  • 这适用于Windows 8:

    1.下载

    2.通过运行cmd测试是否安装良好,并输入以下说明
    转换logo:logo.miff然后运行imdisplay logo.miff

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

    打开config/environments/development.rb

    添加以下行:曲别针。选项[:命令\u路径]=“C:\tools\GnuWin32\bin” 如果您的rails服务器当前正在运行,请停止服务器,然后再次运行rails s。之后,您应该准备就绪。在您的应用程序上上载图像