A Ruby-on-Rails bug with CoffeeScript?
Anyone know why RoR isn't serving the CoffeeScript correctly?
in my application view:
<%= javascript_include_tag :defaults %>
in the browser, this shows up as:
<script src="/assets/defaults.js" type="text/javascript"></script>
But when I click on that link, defaults.js is not found.
<!DOCTYPE 开发者_如何转开发html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Action Controller: Exception caught</title>
<style>
body { background-color: #fff; color: #333; }
body, p, ol, ul, td {
font-family: helvetica, verdana, arial, sans-serif;
font-size: 13px;
line-height: 18px;
}
pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}
a { color: #000; }
a:visited { color: #666; }
a:hover { color: #fff; background-color:#000; }
</style>
</head>
<body>
<h1>Routing Error</h1>
<p><pre>No route matches [GET] "/assets/defaults.js"</pre></p>
</body>
</html>
In Rails 3.0, this :defaults
argument was actually what was known as a JavaScript expansion, configured by Rails to expand out to include the Prototype files at public/javascripts.
In Rails 3.1, there is no longer these JavaScript expansions, but rather there's manifest files. Therefore you should not be using javascript_include_tag :defaults
for this, but rather javascript_include_tag :application
, which is the default JavaScript manifest file for your application.
In a default Rails 3.1 application, there's a app/assets/javascripts/application.js
file which contains directives for Sprockets for which files to require. I've begun work on an Asset Pipeline guide for Rails which explains how these files work and what the directives mean.
精彩评论