Why does = javascript_include_tag :defaults not work in a haml layout in Rails 3.1
Man, WTH is going on with this stuff. You know what that line actually does in Rails 3.1?
<script src="/assets/defaults.js" type="text/javascript"></script>
As they say on ESPN, "Come on, man."
I know that assets are no longer treated as second-class citizens. But it seems as if they are unable to even receive a green card in this release candidate. In the new 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 .
Soooo开发者_如何学Pythono. Am I supposed to download jquery? What do I do? Because there's nothing in that javascripts directory except application.js.
Aggravating. And yet it's free, so how am I complaining? Anyway, these issues seem pretty basic, but I would appreciate any help you can offer.
In Rails 3.1 there is no longer a "defaults" as such, but rather what is specified in your application.js
file are the "defaults". You would include this file using this line:
javascript_include_tag "application"
The jquery
and jquery_ujs
files come with the jquery-rails
gem which is in the default Rails 3.1 Gemfile
.
The //= require
line in that file tells Sprockets that you want to require a file which in this case would be jquery.js
from within jquery-rails
, where the //= require_tree .
will require all other JavaScript files in the same directory as application.js
and concatenate them all into one file.
You can read more about the asset pipeline here.
精彩评论