0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Rails5 特定のページに特定のscssを読み込ませる

Posted at

application.scssのrequire_tree . を削除

require_tree .

これはassests/stylesheets以下の全てのcss,scssを読み込むという設定です。
これを削除しちゃいましょう。

config/initializers/assets.rbのコメントアウトを解除

一番下の行の

# Rails.application.config.assets.precompile += %w( admin.js admin.css )

このコメントアウトを解除し、

Rails.application.config.assets.precompile += %w( top.scss )

を記入します。

任意のhtml.erbファイルの最初にlink_tagを追加

top.html.erb
<%= stylesheet_link_tag 'top' %>

書いてみましたが、かなり強引な気がする。。。
もっといいやり方を知っている方、ご教示していただければ幸いです。。

読んでくださりありがとうございました!

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?