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

时间:2013-11-13 18:40:48

标签: ruby-on-rails ruby twitter-bootstrap bootstrap-sass

我有一个使用gem bootstrap-sass在我的本地计算机上开发的rails应用程序。这一切在开发中都运行良好,但当我将我的应用程序部署到生产服务器时,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'

2 个答案:

答案 0 :(得分:7)

config.assets.compile设置为true不是最佳解决方案,考虑到性能问题。

您可能想尝试RAILS_ENV=production bundle exec rake assets:precompile并重新启动服务器。

答案 1 :(得分:0)

通过设置

解决了这个问题
config.assets.compile = true