Rails:Jquery/Javascript无法从正确的资产位置加载

Rails:Jquery/Javascript无法从正确的资产位置加载,javascript,jquery,ruby-on-rails,Javascript,Jquery,Ruby On Rails,我的Jquery和Javascript有问题。我一直在构建一个应用程序,使用github在工作和家庭之间进行处理。在工作中,一切正常,我的Jquery都正常。当我在家拉应用程序时,jquery和javascript没有响应。这包括我从引导中使用的javascript 浏览器的javascript控制台显示了一些错误,这些错误似乎是问题的根源,但我不确定如何着手修复它们 我的应用程序布局包括: <head> <link href="css/bootstrap.min.css"

我的Jquery和Javascript有问题。我一直在构建一个应用程序,使用github在工作和家庭之间进行处理。在工作中,一切正常,我的Jquery都正常。当我在家拉应用程序时,jquery和javascript没有响应。这包括我从引导中使用的javascript

浏览器的javascript控制台显示了一些错误,这些错误似乎是问题的根源,但我不确定如何着手修复它们

我的应用程序布局包括:

<head>
  <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
  <title>Website</title>
  <%= javascript_include_tag "application" %>
  <%= stylesheet_link_tag    "application", media: "all" %>
  <%= csrf_meta_tags %>

</head>
   ...
   <body>
   ...
   <script src="/js/bootstrap.min.js"></script>
   </body>
我还应该检查或尝试更改什么

我的浏览器javascript控制台也会抛出一些错误:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/requests/css/bootstrap.min.css
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/requests/js/bootstrap.min.js
请求是我的模式之一。根据我当前使用的mvc,它将搜索这些文件夹中的资源。例如,当我尝试使用“ecn”视图中的javascript时,会出现以下错误:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/ecns/css/bootstrap.min.css
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/ecns/js/bootstrap.min.js

为什么rails要在资产文件夹之外的任何文件夹中查找资产?

首先,您应该删除应用程序布局中的行
,因为您的
应用程序.js
已经包含
bootstrap.min.js
(正是这一行:
/=require bootstrap.min.js
),所以不需要包含它两次,这一行同样的
您应该删除它

第二件事是您从控制台得到的错误:

Failed to load resource: the server responded with a status of 404 (Not Found)    http://localhost:3000/requests/css/bootstrap.min.css
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/requests/js/bootstrap.min.js
您的应用程序似乎试图从名为
requests/js
requests/css
的文件夹中加载
bootstrap.min.js
requests/css
,您已经有这样的文件夹了吗? 我认为引导生成器将使用
/app/assets
目录,如果您使用的Rails>=3正好
app/assets/javascripts/
app/assets/stylesheets/


我认为这个railscast也可以帮助您

浏览器的JavaScript控制台中是否有错误?什么是“不响应”意思?我不确定如何检查浏览器的JavaScript控制台。通过不响应,如果我有一个按钮来打开一个模式,当我点击按钮时,浏览器“抽动”,什么都不会发生,但是窗口跳回到topscratch,我找到了控制台,它确实有错误:我在上面添加了它们是的,我注意到它正在查找不存在的文件夹。“requests”是我最近使用scaffold生成器生成的一个表,但是我所有的样式表和js都在assets文件夹中sense@sabrams我想你之所以会犯这些错误,是因为我在回答中注意到了两行字,尝试删除它们,然后查看错误是否仍然与没有影响的相同。我注意到,根据我在应用程序上打开的视图,javascript错误会查看该文件夹:
GEThttp://localhost:3000/ecns/js/bootstrap.min.js 404(未找到)
GEThttp://localhost:3000/requests/js/bootstrap.min.js 404(未找到)
是什么导致它在这些文件夹而不是资产文件夹中查找?不知道:(但您是谁在application.js文件中添加了这一行//=require bootstrap.min.js?请尝试删除这一行,如果没有发生任何情况,请尝试将其放在//=require\u树之前。
Failed to load resource: the server responded with a status of 404 (Not Found)    http://localhost:3000/requests/css/bootstrap.min.css
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/requests/js/bootstrap.min.js