背景图片不显示在heroku [英] Background image not showing up in heroku

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

问题描述

我的heroku网站的背景图片有问题,请在本地使用

I'm having issues with the background image for my heroku site, locally using

background-image: url('background_stripe.png');

可以正常工作,但部署时文件损坏

works but when deployed the file is broken

我尝试使用

background-image: image-url('background_stripe.png');
background-image: url(image-url('background_stripe.png'));
background-image: url(image_url('background_stripe.png'));

没有一个在本地或在heroku上工作。

none of which worked locally or on heroku.

使用bash我发现heroku已将图像文件命名为background_stripe.png,但没有散列和破损的图像。

Using bash I've found out heroku has named the image file background_stripe.png but it has no hash and its a broken image

推荐答案

在您的production.rb中添加以下行

In your production.rb add the following line

config.serve_static_assets = true
config.assets.compile = true

或者您可以尝试使用

RAILS_ENV=production rake assets:precompile

这篇关于背景图片不显示在heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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