我有几个rails 3.1应用程序,我在所有这些问题.
我有一堆包含在我的application.js文件中的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包含标签如下所示:
<script src="/assets/jquery.js?body=1" type="text/javascript"></script> <script src="/assets/jquery-ui.js?body=1" type="text/javascript"></script> <script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script> <script src="/assets/application.js?body=1" type="text/javascript"></script> <script src="/assets/animation_elements.js?body=1" type="text/javascript"></script> <script src="/assets/categories.js?body=1" type="text/javascript"></script> <script src="/assets/faceBox.js?body=1" type="text/javascript"></script> …
那么什么鬼?这样做的结果是各种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