JS文件双重包含在rails app中

我有几个rails 3.1应用程序,我在所有这些都遇到了这个问题。

我有一堆js文件包含在我的application.js文件中。 这是我的application.js:

//= require jquery //= require jquery-ui //= require jquery_ujs //= require_self //= require_tree . 

问题是,当development.rb,我将config.assets.debug设置为true时,我的所有javascript文件都会被包含在标头中。 实际上,它们并未明确地包含在内,而是单独包含一次,一次包含在已编译的application.js文件中。 js包含标签如下所示:

  

那到底是什么? 结果是各种JQuery onClick()行为正在执行两次,其他废话。 这有什么问题? 为了记录,这是我的整个development.rb文件:

 Geobooks::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.cache_classes = false # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Show full error reports and disable caching config.consider_all_requests_local = true #config.action_view.debug_rjs = true config.action_controller.perform_caching = false # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger config.active_support.deprecation = :log # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin #for devise config.action_mailer.default_url_options = { :host => 'localhost:3000' } # Do not compress assets config.assets.compress = false # Expands the lines which load the assets config.assets.debug = false end 

听起来好像您可能在某个时候预编译了您的资产。 检查正在开发中提供的application.js文件的内容。 我的猜测是你会看到所有其他所需文件的捆绑内容。 要解决此问题,只需删除/public/assets/javascripts/application.js并退回服务器即可。

如果这不起作用,找出第二个副本来自哪里(使用Firebug或类似方法检查服务文件)并发布更新,我会看到我能做什么。