Rails 缺少图像 [英] Rails missing image

查看:41
本文介绍了Rails 缺少图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用回形针将图像上传到我的 rails 应用程序.这可能是一个非常简单的修复,但如何或在哪里保存丢失的图像?这是由于没有任何丢失图像而产生的错误.我该如何更改?

I am currently using paperclip to upload images to my rails app. This is probably a very simple fix but how or where do I save the missing images to? This is the error that is produced from not having any missing images. How do I change this?

ActionController::RoutingError (No route matches "/photos/normal/missing.png"):

推荐答案

如果你不需要对默认图像进行任何控制,我认为你不需要,你可以把它放在 下的任何文件夹中RAILS_ROOT/public/images/

If you don't need any control over the default image, which I don't think you need, you can place it in any folder under RAILS_ROOT/public/images/

只需确保您在附件模型中使用 :default_url 参数 指出它.因此,例如,如果您将图像放置在 RAILS_ROOT/public/images/normal/missing.png 中,则不需要像这样指定路径:

Just make sure you point it out in the attachment model with the :default_url parameter. So for example if you place the image in RAILS_ROOT/public/images/normal/missing.png you need t specify the path like this:

has_attached_file :photo, :default_url => "/images/normal/missing.png"

这篇关于Rails 缺少图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆