A
A
Alexander Petrov2016-03-28 14:18:16
Ruby on Rails
Alexander Petrov, 2016-03-28 14:18:16

Why doesn't rails_admin want to upload an image?

In general, I made a download from paperclip. Everything loads fine locally. When uploaded to the server and launched in production, when loading the image, the following error appears:
Image failed to be created
- Image has contents that are not what they are reported to be
after a long googling, it became known that it was swearing at the validator.
I have this:
validates_attachment_content_type :image, :content_type => ['image/jpeg', 'image/png']
tried to disable validation, but it didn't work(((

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Petrov, 2016-03-29
@Mirkom63

In general, I dug up such a solution at some American forum.
Make file: /config/initializes/paperclip.rb
require 'paperclip/media_type_spoof_detector'
module Paperclip
class MediaTypeSpoofDetector
def spoofed?
false
end
end
end
Who understands what this is and can explain why this solves the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question