伙计,WTH正在处理这些东西。您知道那条线在Rails 3.1中实际上是做什么的吗?
<script src="/assets/defaults.js" type="text/javascript"></script>
正如他们在ESPN上所说:“加油,伙计。”
我知道 Assets 不再被视为二等公民。但是似乎他们甚至都无法在此候选版本中收到绿卡。在新的app/assets/javascripts/application.js中:
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
太好了我应该下载jquery吗?我该怎么办?因为除了application.js之外,该javascripts目录中没有其他内容。
加重。但是它是免费的,那么我该如何提示?无论如何,这些问题似乎很基础,但是我会很感激您能提供的任何帮助。
最佳答案
在Rails 3.1中,不再有这样的“默认值”,而是在application.js
文件中指定的是“默认值”。您可以使用以下行包含此文件:
javascript_include_tag "application"
jquery
和jquery_ujs
文件与jquery-rails
gem一起提供,后者在默认的Rails 3.1 Gemfile
中。该文件中的
//= require
行告诉Sprockets,您想要一个文件,在这种情况下,该文件将是jquery.js
中的jquery-rails
,其中//= require_tree .
将需要与application.js
相同目录中的所有其他JavaScript文件,并将它们全部连接到一个文件中。您可以阅读有关the asset pipeline here的更多信息。
关于ruby-on-rails - 为什么= javascript_include_tag :defaults not work in a haml layout in Rails 3. 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6886391/