当前位置 : 主页 > 编程语言 > ruby >

ruby-on-rails – Rails 4:Bootstrap-sass gem资产可用于开发,但不适用于生产

来源:互联网 收集:自由互联 发布时间:2021-06-23
我有一个rails应用程序,我使用gem bootstrap-sass在我的本地机器上开发.这一切在开发中都运行良好,但当我将我的应用程序部署到生产服务器时,glyphicons停止工作. 控制台中出现错误,指出:
我有一个rails应用程序,我使用gem bootstrap-sass在我的本地机器上开发.这一切在开发中都运行良好,但当我将我的应用程序部署到生产服务器时,glyphicons停止工作.

控制台中出现错误,指出:

downloadable font: download failed (font-family: "Glyphicons Halflings" style:normal 
 weight:normal stretch:normal src index:1): status 2147746065 
 source: http://mydomain.com/assets/bootstrap/glyphicons-halflings-regular.woff

确实没有这样的文件,但是具有资产管道摘要的同一文件.所以在我看来,资产管道文件的请求被破坏,因此试图获取正常文件?或者我的资产管道坏了吗?不太确定.并不确定为什么它可以在我的本地机器上运行,但不能在服务器上运行.

我是否必须以不同方式配置我的production.rb?

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

# Generate digests for assets URLs.
config.assets.digest = true

# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
考虑到性能问题,将config.assets.compile设置为true并不是最佳解决方案.

您可能想尝试RAILS_ENV =生产包exec rake资产:预编译和重启服务器.

网友评论