我的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
思想?
答案 0 :(得分:3)
两种环境都包含所有的javascript。默认情况下,在生产模式下,rails资产管道组合/缩小了您的javascript(和css),这减少了浏览器/客户端对服务器所需的请求量。
有关导轨指南中资产管道的详细说明: