Ruby on rails - 1 bug prevented this enum from being saved: image has content that is not what they are reporting

Bug 1 prevented this listing from being saved: Image has content that is not what they are reporting.

This is the error I get when I try to upload an image to print. I've tried various types of validations and nothing seems to work.

This is what my Model looks like .

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

      

Can someone explain to me what I did wrong and what I can do to fix it. I really want to keep working on this app, but I got into a problem!

+3


source to share


3 answers


You need to change the following

validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]

      



Also make sure you are actually loading images with the specified extensions

+2


source


This could be because you don't have a program file

(perhaps you are not using a Unix system?)

file

used with paperclip to check if the uploaded file is what it should be (based on your validator).

If you are on Windows, you must manually download and install the Windows file and add it to



  • Windows environment variable PATH,

  • project environment ( config/environments/development.rb

    , add line Paperclip.options[:command_path] = '{your_path_to_dir_with_file/bin}'

    )

After that restart your console, server and it should work.

+1


source


This is what you can do for windows only :

  • Install exe with
  • download exe from this link file.exe
  • test if it is well installed, run your cmd and put the following instructions convert logo: logo.miff

    , then run 'imdisplay logo.miff' you will get a custom logo that will appear on your window screen.

Now you can start configuring everything on the rails app

  • Open up config/environments/development.rb

    1. Add the following line: Paperclip.options[:command_path] = 'C:\Program Files (x86)\GnuWin32\bin'

    2. If your rails server is currently running, lock the server and then start s rails again. After that, you should be ready to go. Upload the image to your app.
0


source







All Articles