記事概要
Ruby on Railsのマニフェストファイルについて、まとめる
前提
- Ruby on Railsでアプリケーションを作成している
基本情報
ファイルパス
app/assets/stylesheets/application.css
記載方法
*=
に続けて他のCSSファイルなどを指定すると、複数のCSSファイルをまとめて読み込むことが可能だが、編集不要
処理概要
アプリケーション全体に適用するCSSを指定できる
まとめ
require_tree
引数として与えられたディレクトリ以下のCSSファイルを、アルファベット順にすべて読み込む機能
require_tree .
の記述によって、app/assets/stylesheets
ディレクトリにある全てのCSSファイルを読み込む
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, if configured) file within this directory, lib/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 other CSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
Ruby on Railsまとめ
ビュー
application.html.erb