LoginSignup
9
10

More than 5 years have passed since last update.

Rails の assets 環境で scss 使う場合の、ちょっと嬉しい小技

Posted at

views/layouts/application.html.haml の body のとこを

%body{class: controller_name, id: action_name}

としておく。 (erb なら <body class='<%= controller_name %>' id='<%= action_name %>' >

こうしておくと、特定のページだけに適用したいスタイルを

/* users.css.scss */
body.users#index {
    table { background-color: silver; }
}

みたいに書けるってぇ寸法だ。
users#indexのとこが routes の表記と揃ってちょっとウレシくない?

9
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10