链接到rails app中的js文件

时间:2013-05-08 11:30:31

标签: javascript ruby-on-rails-3

我一直在转换我的css样式,并设法弄乱了以某种方式链接到js文件。

控制台说

GET http://0.0.0.0:3000/assets/js/bootstrap.js 404 (Not Found)

但我不确定在应用中引用它的位置或如何解决它

我的application.html.erb是

<%= stylesheet_link_tag "application", :media => "all" %>
    <%= javascript_include_tag "application" %>
    <%= analytics_init if Rails.env.production? %>

     <%= csrf_meta_tags %>
    <script type="text/javascript">
            function clearDefault(el) {
                if (el.defaultValue==el.value) el.value = ""
            }

            function clearText(){
            search = $('.search-query');
            if (search.defaultValue==search.value)
            search.value = ""
            }

            $(document).ready(function() {
                $('.collapse').collapse();
            });
        </script>
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js">
      </script>
    <![endif]-->
    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="assets/ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">

        <script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-38571594-1']);
  _gaq.push(['_setDomainName', 'guidelinesforme.com']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

我的application.js是

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .

$(".collapse").collapse()

2 个答案:

答案 0 :(得分:0)

查看app / assets / application.js下面的行是否还在那里?

//= require_tree .

或者您是否从app / assets / javascripts中删除了bootstrap.js文件?

答案 1 :(得分:0)

我已经解决了问题 - 我必须更换require_tree。 with require bootstrap