简体   繁体   English

无法在heroku上显示图像

[英]unable to display images on heroku

When i run the website locally, it works fine.However, after pushing to heroku, its displaying as a broken image 当我在本地运行网站时,它工作正常。但是,在推送到heroku后,它显示为一个破碎的图像

The pictures are in my /assets/images/ folder 图片在我的/ assets / images /文件夹中

images are called in my static page like this 像这样在我的静态页面中调用图像

<img src="assets/blank_avatar_male.jpg" alt="blank_male_avatar">

Ive tried changing the path to /assets/images/jpeg and it and repushed. 我已经尝试将路径更改为/ assets / images / jpeg并将其删除。 No luck so far. 到目前为止没有运气。 Any suggestions on how to fix this? 对于如何解决这个问题,有任何的建议吗?

My guess is that you don't have config.serve_static_assets set to true in your production.rb file. 我的猜测是你没有在production.rb文件中将config.serve_static_assets设置为true。

The simplest solution is to include the rails_12factor gem which will do this for you 最简单的解决方案是包含rails_12factor gem,它将为您完成此操作

try compiling your assets locally like this: 尝试在本地编译您的资产,如下所示:

RAILS_ENV=production bundle exec rake assets:precompile

and then push to heroku 然后推送到heroku

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM