在Heroku上加载两次资产

时间:2013-03-07 23:24:38

标签: ruby-on-rails heroku asset-pipeline

我正在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>

所有jqueryjquery_ujsdropdownregistrationjquery.Jcropclean也会在{application中连接(缩小){ {1}}。我不明白为什么在只加载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

1 个答案:

答案 0 :(得分:1)

看起来您的问题是您已在生产中设置了config.assets.debug = true。尝试将config.assets.debug = false添加到production.rb