Rails javascript_include_tag以某种方式拉入所有文件

时间:2013-06-29 03:42:16

标签: ruby-on-rails

我在布局视图中有这个

<%= stylesheet_link_tag    "application", :media => "all" %>
<%= javascript_include_tag "jquery-1.10.1.min" %>
<%= javascript_include_tag "bootstrap.min" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>

为什么我在页面呈现时获得所有这些?

<link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/jquery-1.10.1.min.js" type="text/javascript"></script>
<script src="/assets/bootstrap.min.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/LZA/LZA.js?body=1" type="text/javascript"></script>
<script src="/assets/LZA/MapKit.js?body=1" type="text/javascript"></script>
<script src="/assets/LZA/Torch.js?body=1" type="text/javascript"></script>
<script src="/assets/LZA/cordova-2.6.0.js?body=1" type="text/javascript"></script>
<script src="/assets/LZA/jquery-1.10.1.min.js?body=1" type="text/javascript"></script>
<script src="/assets/LZA/jquery-1.9.1.min.js?body=1" type="text/javascript"></script>
<script src="/assets/LZA/jquery.form.js?body=1" type="text/javascript"></script>
<script src="/assets/LZA/jquery.mobile-1.3.1.min.js?body=1" type="text/javascript"></script>
<script src="/assets/apps.js?body=1" type="text/javascript"></script>
<script src="/assets/bootstrap.min.js?body=1" type="text/javascript"></script>
<script src="/assets/home.js?body=1" type="text/javascript"></script>
<script src="/assets/simulator.js?body=1" type="text/javascript"></script>
<script src="/assets/webservice.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>

我所做的只是将一些.css.js个文件添加到文件夹中,以便我可以在网站的其他位置使用它们...

1 个答案:

答案 0 :(得分:1)

看看你的application.js文件(或其他任何文件),您应该看到类似

的内容
//= require home
//= require simulator
//= require webservice

这会提取名为home.jssimulator.jswebservice.js的文件,并将其添加到您的网站。

查看Rails Assets Pipeline