简体   繁体   English

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

[英]Rails 4: Bootstrap-sass gem assets work on development but not on production

I have a rails app that I developed on my local machine using the gem bootstrap-sass. 我有一个rails应用程序,我使用gem bootstrap-sass在我的本地机器上开发。 It all worked fine in development, but when I deployed my app to the production server the glyphicons stopped working. 这一切在开发中都运行良好,但当我将我的应用程序部署到生产服务器时,glyphicons停止工作。

There's an error in the console that says: 控制台中出现错误,指出:

 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

And indeed there is no such file, but the same file with an asset pipeline digest. 确实没有这样的文件,但是具有资产管道摘要的同一文件。 So it seems to me the request to the asset pipeline file is broken and therefore tries to get the normal file? 所以在我看来,资产管道文件的请求被破坏,因此试图获取正常文件? Or is my asset pipeline broken? 或者我的资产管道坏了吗? Not really sure. 不太确定。 And not really sure why it works on my local machine but not on the server. 并不确定为什么它可以在我的本地机器上运行,但不能在服务器上运行。

Do I have to configure my production.rb differently? 我是否必须以不同方式配置我的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'

Setting config.assets.compile to true is not the best solution, considering performance stuff. 考虑到性能问题,将config.assets.compile设置为true并不是最佳解决方案。

You may want to try RAILS_ENV=production bundle exec rake assets:precompile and restart server. 您可能想尝试RAILS_ENV=production bundle exec rake assets:precompile和重启服务器。

通过设置解决了它

config.assets.compile = true

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

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