1

我的application.js文件如下所示:

//= require jquery
//= require jquery_ujs
//= require rails.validations
//= require_tree .

我的开发站点在源代码中有这个:

<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/rails.validations.js?body=1" type="text/javascript"></script>
<script src="/assets/home.js?body=1" type="text/javascript"></script>
<script src="/assets/industries.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery-1.7.1.min.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.ba-hashchange-v1.3.min.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.flexslider-v1.8.min.js?body=1" type="text/javascript"></script>
<script src="/assets/main-r6.js?body=1" type="text/javascript"></script>
<script src="/assets/welcome.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>

但我的作品是这样的:

<script src="/assets/application-b5f7c629f9622da89d5cc703e459e6c3.js" type="text/javascript"></script> 

我的config/environments/development.rb有这个:

config.assets.compress = false

我的config/environments/production.rb有这个:

  config.serve_static_assets = false    
  config.assets.compress = true    
  config.assets.compile = true
  config.assets.digest = true

想法?

4

1 回答 1

3

两种环境都包括所有的 javascript。默认情况下,在生产模式下,rails 资产管道组合/缩小您的 javascript(和 css),这减少了浏览器/客户端需要向服务器发出的请求数量。

rails 指南中有对资产管道的详细解释:

http://guides.rubyonrails.org/asset_pipeline.html

于 2012-06-18T21:47:29.160 回答