载波默认图像不显示 [英] Carrierwave default image doesn't display

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

问题描述

我正在尝试在Rails 3.2应用程序中显示默认图像。我已按照Carrierwave github页面上的说明进行操作,并浏览了一些Stackoverflow帖子。但是,由于某种原因,它仍然无法正常工作。

I'm trying to have a default image display in my Rails 3.2 application. I've followed the instructions on the Carrierwave github page and have looked through several Stackoverflow posts. But, for some reason it's still not working.

这是我的代码:

在我的photo_uploader.rb中我已启用的文件:

In my photo_uploader.rb file I've enabled this:

def default_url
  "/images/" + [version_name, "default.png"].compact.join('_')
end

在我的表单中并显示我正在访问这样的图像:

In my form and show views I'm accessing the image like this:

<%= image_tag @user.photo.url %>

我的图片的路径为:

/app/assets/images/default.png

在我的application.rb我添加了以下行,因为它应该允许提供静态资产:

In my application.rb I've added the following line because that's supposed to allow static assets be served up:

config.serve_static_assets = true

但是,我的服务器在加载页面时显示以下内容:

However, my server is showing the following when the page is loaded:

ActionController::RoutingError (No route matches [GET] "/images/default.png")

我也尝试过重新编译我的资产。

I've also tried re-compiling my assets.

关于我的想法

推荐答案

这是资产管道问题。

尝试获取 /assets/default.png (放下图像/)

Try getting /assets/default.png (drop the images/)

此处的更多信息: http://guides.rubyonrails.org/asset_pipeline.html

这篇关于载波默认图像不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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