按照之前stackoverflow post中的步骤,在我的rails应用程序中安装Wrap bootstrap主题后;我的应用程序无法找到我的样式表和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
*/
来自Inspect / Console的错误:
JS文件位置:
/用户/用户/代码/ BV_main /应用程序/资产/ Javascript角
CSS文件位置:
/用户/用户/代码/ BV_main /应用程序/资产/样式表
字体文件位置:
/用户/用户/代码/ BV_main /应用程序/资产/字体
索引文件的位置与我的欢迎控制器的观点一致:
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
答案 0 :(得分:0)
有两个问题导致此问题现在通过以下步骤解决。
自:
<img class="img-responsive" src="images/humanity-logo.png" alt="" />
致:
<%= image_tag('humanity-logo', class: 'img-responsive') %>
我错过了因为无法使用jquery而需要的application.js文件。所以我创建了一个application.js文件,其中只有以下条目:
//= require jquery
//= require_tree .