html - 如何在 Ruby on Rails 应用程序中更改 Index.html 的头部部分?

标签 html css ruby-on-rails ruby twitter-bootstrap

在我的 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">

我已将 bootstrap CSS 和 JS 文件添加到 app/assets/stylesheetsapp/assets/javascripts 并更改了 application.cssapplication.js 文件。我仍然无法在源代码中看到这些文件。

最佳答案

  1. 您需要使用 require_tree . 或明确地要求这些文件

    application.css

    /*
    *= require self
    *= require_tree .
    */
    

    application.css

    //= require self
    //= require_tree .
    
  2. 你可以使用content_for标签

    application.html.haml

    %head
      = yield :head   
    

    index.html.haml

    = content_for :head do
      = javascript_include_tag "bootstrap"
    

关于html - 如何在 Ruby on Rails 应用程序中更改 Index.html 的头部部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38589670/

相关文章:

jquery - javascript 在 Rails 4 中的 link_to 之后停止工作

ruby-on-rails - 命名 Rails 模型以避免冲突的好方法是什么?

javascript - 单张 OSM : Center mapview on polygon

javascript - 滑动动画损坏

javascript - 如何在html复选框值参数中使用javaScript变量?

php - 屏幕上的div定位

css - 如何在调整大小时阻止 <div> 的内容开始新行?

html - Bootstrap 标签在堆叠前重叠

html - div 无法以高度 :auto 滚动

ruby-on-rails - 将数组存储在数据库 : JSON vs. 序列化数组中