1

我在 heroku 上运行 rails 3.2.11。我的脚本被加载了两次,导致:

<script src="/assets/jquery-08bbde0e2625ba65b3f4d03e5cf1c05d.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs-a3266ec390218bd1ea234887ff70ab4e.js?body=1" type="text/javascript"></script>
<script src="/assets/dropdown-504c410c0872c88a73fa906195712053.js?body=1" type="text/javascript"></script>
<script src="/assets/registration-db60840d5dd61a97052f0d3fe669f478.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.Jcrop-9819495b75d1a185b32ae5bcf2b071fe.js?body=1" type="text/javascript"></script>
<script src="/assets/clean-42820428d4061c499712d032b87a19e7.js?body=1" type="text/javascript"></script>
<script src="/assets/application-5a65a574df27b941748dc66c7373b32b.js?body=1" type="text/javascript"></script>

所有的jquery, jquery_ujs, dropdown, registration,jquery.Jcropclean也在application. 我不明白为什么只application应该加载这些文件。

以下是 的内容application.js

//= require jquery
//= require jquery_ujs
//= require dropdown
//= require 'registration'
//= require 'jquery.Jcrop'
//= require clean

我如何将它包含在我的布局中:

= javascript_include_tag 'application'

内容application.rb(部分与资产有关):

# Enable the asset pipeline
config.assets.enabled = true
config.assets.initialize_on_precompile = false
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true

config.assets.precompile += [
  'active_admin.js',
  'application.js',
  'landing.js.coffee',
  'active_admin.css.scss', 
  'application.css.sass',
  'landing.css.sass'
  ]

内容production.rb(部分与资产有关):

# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = true
4

1 回答 1

1

看起来您的问题是您已config.assets.debug = true投入生产。尝试添加config.assets.debug = falseproduction.rb.

于 2013-03-08T01:58:29.310 回答