0

我正在构建一个 Rails 应用程序,但我遇到了一个问题,即弹出两个确认框,而不是使用 :confirm 时弹出一个。

我得出的结论是,这是rails.js被包含两次的结果,一次在我的布局中,一次在application.js. <%=javascript_include_tag "rails.js"%>但是,当我从中删除application.html.erb并在应用程序上查看页面源时,它仍然显示它被包含在内。

我尝试删除浏览器缓存,重新启动浏览器,进入隐身模式,清理资产管道,确保config.assets.debug = false. 关于如何缓解这个问题的任何想法?谢谢。

application.html.erb 的头部:

    <head>
       <%= csrf_meta_tag %>
        <meta charset="utf-8">
        <!-- [if IE]>  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
        <title>Title</title>
        <meta name="description" content="">
        <!-- <meta name="viewport" content="width=device-width"> -->
        <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

        <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<%= javascript_include_tag "application" %>
        <%=stylesheet_link_tag("normalize")%>
        <%=stylesheet_link_tag("main")%>
        <%=stylesheet_link_tag("r")%>
        <%=stylesheet_link_tag("webfonts/ss-standard")%>
        <!--link type="text/css" href="css/jquery.jscrollpane.css"-->




        <%=javascript_include_tag "vendor/modernizr-2.6.1.min"%>
        <%=javascript_include_tag "//use.typekit.net/rwg2mxn.js"%>      
        <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
        <%=javascript_include_tag "jquery.cookie.js"%>
        <!--script type="text/javascript" src="http://platform.linkedin.com/in.js">
            api_key: YOUR_API_KEY_GOES_HERE
            authorize: true
        </script-->
        <%=javascript_include_tag "plugins.js"%>
        <%=javascript_include_tag "vendor/jquery.touchSwipe.min"%>
        <!--script src="js/vendor/jquery.mousewheel.js"></script>
        <script src="js/vendor/jquery.jscrollpane.min.js"></script-->

    <%=yield :head%>

    </head>

应用程序.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-fileupload/basic
//= require jquery-fileupload/vendor/tmpl
//= require_tree .
4

1 回答 1

1

Rails 会将你所有的 js 文件包含在 app/assets/javascripts 中,因为

应用程序.html.erb

javascript_include_tag "应用程序"

应用程序.js

//= 要求树

如果您不想导入 rails.js,则必须从 app/asssets/javascript 目录中删除该文件。

于 2013-04-05T21:14:03.370 回答