Answer the question
In order to leave comments, you need to log in
How to fix error loading image in Paperclip?
Can't get Paperclip to load image in simple_form.
When sending content, it gives in the image line: "has contents that are not what they are reported to be".
I couldn't find any information about this error on Google.
gem 'paperclip', '~> 4.2.2'
Model:
has_attached_file :image, styles: { medium: "700x500#", small: "350x250#" }
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z /
Controller:
def post_params
params.require(:post).permit(:image)
end
View:
<%= image_tag post .image.url(:medium) %>
simple_form form:
<%= simple_form_for post do |f| %>
<% end %>
Answer the question
In order to leave comments, you need to log in
<%= simple_form_for post , html: {multipart: true} do |f| %>
<%= simple_form_for @post, html: {multipart: true} do |f| %> - no change
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question