railsでcssを適用させたいのですがうまくいきません。
application.html.erb(head抜粋)
<head> <title>UberEvaluation</title> <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <style type="text/css"> <!-- a:visited { color:white; text-decoration:none } --> </style> </head>
application.scss
/* * 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, 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/SCSS * 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 index.scss *= require_tree */
index.scss
body { background-color: red; }
googlechromeデベロッパーツールではファイル読み込まれていました
<link rel="stylesheet" media="all" href="/assets/index.self-d3a10623443304cb8c2c49a56a9da806ef4a006d23c28a0dc86f4a7ab7de5900.css?body=1" data-turbolinks-track="reload"> <link rel="stylesheet" media="all" href="/assets/application.self-df590ce0310e5452b08cf38c9c12bd005dd1be4eb3522e1693a1f2b37a7d3959.css?body=1" data-turbolinks-track="reload">
やったこと
・headからindex.scss直接ファイルを指定した
・Rails.application.config.assets.precompile += %w( application.css )による直接指定
・bundle exec rails assets:precompile RAILS_ENV=production による手動プリコンパイル
一人zや
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/09/25 23:44