Skip to content

Instantly share code, notes, and snippets.

@lsissoko
Last active November 16, 2015 14:30
Show Gist options
  • Save lsissoko/f8e47aa81edfbffff8fa to your computer and use it in GitHub Desktop.
Save lsissoko/f8e47aa81edfbffff8fa to your computer and use it in GitHub Desktop.
thoughtbot/paperclip Image Validation

When attaching a file in a Rails app via Paperclip, you may get an error like:

Validation failed: Image has an extension that does not match its contents

To resolve this, create the file config/initilizers/paperclip.rb and then restart your server.

#config/initilizers/paperclip.rb
require 'paperclip/media_type_spoof_detector'
module Paperclip
  class MediaTypeSpoofDetector
    def spoofed?
      false
    end
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment