我正在构建一个rails应用程序,我遇到了一个问题,我正在弹出两个确认框,而不是我使用时的确认框:确认。
我得出结论,这是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>
的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-fileupload/basic
//= require jquery-fileupload/vendor/tmpl
//= require_tree .
答案 0 :(得分:1)
Rails将包含app / assets / javascripts中的所有js文件,因为
application.html.erb
javascript_include_tag“申请”
并且
的application.js
// = require_tree
如果您不想导入rails.js,则必须从app / asssets / javascript目录中删除该文件。