在本地使用 Puma 运行我的 ROR 应用程序。尝试加载 javascript/application.js 时出现以下错误
Failed to load resource: the server responded with a status of 404 (Not Found) javascript/application.js
请记住,这是一个 Ruby 1.9.3 应用程序,我刚刚将 GEM 文件更新为 2.3.1
在本地运行 Rails 应用程序时是否需要更改任何内容?
源代码显示
<script src="/javascripts/application.js"></script>
<link href="/bootstrap.min.css" rel="stylesheet">
<link href="/bootstrap-responsive.min.css" rel="stylesheet">
最佳答案
在本地,javascript 文件应位于 app/assets/javascripts
下。它们将在 Assets 编译(部署)期间被压缩、缩小并复制到 public
看起来 /public/javascripts
下没有 js 文件,因此您收到 404 错误。
还值得检查您是否在开发模式下启动应用程序。否则,rails 将在 public
中查找 js 和 css 文件。
参见https://guides.rubyonrails.org/asset_pipeline.html#asset-organization更多细节。
关于javascript - 无法加载资源: the server responded with a status of 404 (Not Found) javascript/application. js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53545047/