在 Heroku/Ruby on Rails 上找不到 PNG [英] PNG not found on Heroku / Ruby on Rails
问题描述
在 Heroku 上部署后未加载 PNG 文件!
PNG Files not loading after deploy on Heroku!
我正在 Heroku 上部署一个项目,并且所有资产都完美运行,包括图像(jpg、jpeg 和 gif),但无法加载 PNG 文件!在一般页面显示:
I am deploying a project on Heroku, and all assets run perfectly, including images (jpgs, jpegs and gifs), but PNG files are not load! In general pages showing:
GET damainname.com/assets/namespace/my_image-867450b295e2051d381123c16c51548e.png 404(未找到)
其他图片文件扩展名(JPG、JPEG 和 GIF)正常加载.
Other image file extensions (JPG, JPEG and GIF) load normally.
我正在使用:
- Heroku cedar(使用和不使用资产进行测试:本地预编译)
- ruby 1.9.3p448(2013-06-27 修订版 41675)[i686-linux]
- Rails 3.2.11
production.rb:
production.rb:
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
config.serve_static_assets = true
config.assets.compress = true
config.assets.compile = false
config.assets.digest = true
application.rb:
application.rb:
config.assets.precompile += ['application.css', 'application.js', 'admin.css', 'admin.js']
config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif]
config.assets.initialize_on_precompile = false
推荐答案
需要检查的三件事.
您的存储库中有
.slugingore
文件吗?如果是这样,请确保其中没有像*.png
Do you have a
.slugingore
file in your repo? If so, ensure there is not an entry in it like*.png
您的 gemfile 中有 gem 'rails_12factor'
gem 吗?https://github.com/heroku/rails_12factor
Do you have the gem 'rails_12factor'
gem in your gemfile? https://github.com/heroku/rails_12factor
在您的 config/application.rb
中,将 config.assets.version
设置为比当前更高的浮点数.IE.从 1.0
增加到 1.1
.
In your config/application.rb
, set config.assets.version
equal to a float higher than it currently is. Ie. increment from 1.0
to 1.1
.
这篇关于在 Heroku/Ruby on Rails 上找不到 PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!