默認情況下,資產管道包括app/assets/stylesheets
中的樣式。從導向:http://guides.rubyonrails.org/asset_pipeline.html
與3.1版本開始,Rails的默認連接所有 JavaScript文件到一個主.js文件和所有的CSS文件合併成一個 主.css文件。正如您將在本指南後面介紹的那樣,您可以通過 自定義此策略,以您喜歡的任何方式對文件進行分組。在 製作中,Rails將MD5指紋插入每個文件名,以便該文件由Web瀏覽器緩存。你可以通過改變這個指紋,只要您更改文件內容自動發生 無效 緩存..
在你/app/assets/stylesheets
目錄,你應該有一個文件名爲application.css
(注意純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 vendor/assets/stylesheets of plugins, if any, 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 top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
還要注意,應該被全部註釋掉這樣的,它是如何Rails的讀取它。
所以我應該在視圖中包含''application''然後呢? –
您的'/ app/views/layout/application.html.erb'文件應該包含在標題中: <%= stylesheet_link_tag「application」,:media =>「all」%> –