[英]How to change the head section of Index.html in a Ruby on Rails app?
In the head section of my Ruby on Rails app I am only able to see the following CSS and JS file when I view the source code in browser. 在Ruby on Rails应用程序的头部,当我在浏览器中查看源代码时,我只能看到以下CSS和JS文件。
<link rel="stylesheet" media="all" href="/stylesheets/default.css" data-turbolinks-track="reload" />
<script src="/javascripts/default.js" data-turbolinks-track="reload">
I have added bootstrap CSS and JS files to the app/assets/stylesheets
and app/assets/javascripts
and have changed the application.css
and application.js
files. 我已将bootstrap CSS和JS文件添加到app/assets/stylesheets
和app/assets/javascripts
,并更改了application.css
和application.js
文件。 Still I am not able to see those files in source code. 仍然无法在源代码中看到这些文件。
You need to require those files using require_tree .
您需要使用require_tree .
要求这些文件require_tree .
or explicitly 或明确地
application.css application.css
/* *= require self *= require_tree . */
application.css application.css
//= require self //= require_tree .
you can use content_for
tag 您可以使用content_for
标签
application.html.haml application.html.haml
%head = yield :head
index.html.haml index.html.haml
= content_for :head do = javascript_include_tag "bootstrap"
In your application.css add the following to include your files 在application.css中添加以下内容以包含文件
*= require bootstrap
*= require default
*= require_tree .
*/
Added <link rel="stylesheet" type="text/css" href="stylesheets/bootstrap.min.css">
to the application.html.erb
file. 已将<link rel="stylesheet" type="text/css" href="stylesheets/bootstrap.min.css">
到application.html.erb
文件。
Thanks to @Deepak for giving me a lead to find an alternate solution to my problem. 感谢@Deepak给我带头寻找解决我的问题的替代方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.