[英]Changing styles in paperclip to adjust image size makes the app display' no file chosen' when uploading an image?
In my model pin.rb 在我的模型中pin.rb
has_attached_file :image, styles: { medium: "320x240>"}
In pin.html.erb 在pin.html.erb中
<td><%= image_tag pin.image(:medium) %></td>
When I upload an image it gives 当我上传图片时
No File Chosen Paperclip::Errors::NotIdentifiedByImageMagickError
没有选择文件的回形针::错误:: NotIdentifiedByImageMagickError
However when I remove "styles..." from pin.rb and '(:medium) from pin.html it works fine. 但是,当我从pin.rb中删除“样式...”并从pin.html中删除'(:medium)时,它可以正常工作。 I want the image size to be adjusted though.
我希望图像尺寸可以调整。
What am I doing wrong? 我究竟做错了什么?
您是否忘了在附件上调用url?
<%= image_tag pin.image.url(:medium) %>
Yes, this is a couple of years old and was never answered 是的,这已经有两年了,但从未得到答复
I'm researching another Paperclip question today, but in this case I would say: 我今天正在研究另一个回形针问题,但在这种情况下,我会说:
<%= image_tag @pin.image.url(:medium) %>
as that's the equivalent of what I have in mine. 因为这相当于我的内在能力。
Don't forget the instance variable in the _form.html.erb as well as the .url method to set the image into the size you want. 不要忘记_form.html.erb以及.url方法中的实例变量来将图像设置为所需的大小。
For any travelers to this page, as a next step you might want to also look at another post here on how to delete the image in the Edit view. 对于前往此页面的所有旅行者,下一步,您可能还要在此处查看另一篇有关如何在“编辑”视图中删除图像的文章。 Rails file upload (paperclip) on edit
Rails文件上传(回形针)在编辑时
Cheers 干杯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.