【发布时间】:2016-03-13 20:48:24
【问题描述】:
按照之前stackoverflow post 中的步骤将Wrap bootstrap 主题安装到我的rails 应用程序后;我的应用程序无法找到我的样式表和 javascript 文件。所有文件都位于“BV_main/app/assets”下的各自目录下。我收到错误消息:加载资源失败:服务器响应状态为 404(未找到)。此外,该应用程序正在寻找我的 application.js 文件,但我没有创建一个,需要吗?任何人都可以提供任何指导吗?
Application.html.erb 文件:
<!DOCTYPE html>
<html>
<head>
<title>BV</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
Application.css 文件:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
检查/控制台错误:
JS 文件位置:
/Users/user/code/BV_main/app/assets/javascripts
CSS 文件位置:
/Users/user/code/BV_main/app/assets/stylesheets
字体文件位置:
/Users/user/code/BV_main/app/assets/fonts
索引文件位置是我的欢迎控制器的视图:
welcome git:(layout) ✗ pwd
/Users/user/code/BV_main/app/views/welcome
✗ ls -ltr index.html.e*
-rw-r--r-- 1 user staff 1015 Feb 29 20:10 index.html.erb_old2016003
-rwxr-xr-x@ 1 user staff 25044 Mar 13 13:41 index.html.erb
【问题讨论】:
-
能否把app/stylesheets/application.css的内容贴出来
-
谢谢刚刚添加
-
所以奇怪的是 404 个位置是错误的。它应该在 /assets/ 中查找 - 而不是在样式表或 javascripts 中,根据您提供的内容,我不明白它为什么这样做。您是否对资产管道进行了其他更改?
-
我想知道那个@trh,谢谢。不,我认为我没有对资产管道进行任何其他更改......
-
我的欢迎控制器下确实有索引文件。即使默认情况下它应该在资产/管道下检查,这是否会影响它在哪里获取我的 js 和图像文件? /Users/user/code/BV_main/app/views/welcome
标签: javascript html css ruby-on-rails twitter-bootstrap