質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Bootstrap

BootstrapはウェブサイトデザインやUIのWebアプリケーションを素早く 作成する可能なCSSフレームワークです。 Twitter風のデザインを作成することができます。

CSS

CSSはXMLやHTMLで表現した色・レイアウト・フォントなどの要素を指示する仕様の1つです。

Q&A

解決済

1回答

2044閲覧

RailsでCSSが反映されない

shimazu

総合スコア38

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Bootstrap

BootstrapはウェブサイトデザインやUIのWebアプリケーションを素早く 作成する可能なCSSフレームワークです。 Twitter風のデザインを作成することができます。

CSS

CSSはXMLやHTMLで表現した色・レイアウト・フォントなどの要素を指示する仕様の1つです。

0グッド

0クリップ

投稿2018/12/29 06:25

編集2018/12/29 06:53

application.scssで

*= require_self
*= require_tree .
がないとapplication.scss以外のcssが反映されません。
イメージ説明
ただ、あると、そもそもcssが反映されん。
イメージ説明

どうすれば、application.scssをテンプレートのcssとして、そのほかを追加のcssとして反映することができますか?

scss

1//application.scss 2/* 3 * This is a manifest file that'll be compiled into application.css, which 4 * will include all the files listed below. 5 * 6 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, 7 * vendor/assets/stylesheets, or vendor/assets/stylesheets of plugins, if any, 8 * can be referenced here using a relative path. 9 * 10 * You're free to add application-wide styles to this file and they'll appear 11 * at the bottom of the compiled file so the styles you add here take 12 * precedence over styles defined in any styles defined in the other CSS/SCSS 13 * files in this directory. It is generally better to create a new file per 14 * style scope. 15 *= require_self 16 *= require_tree . 17*/ 18// Custom bootstrap variables must be set or imported *before* bootstrap. 19@import "bootstrap";

scss

1//order.scss 2.table-striped>tbody>tr:nth-child(odd)>td, 3.table-striped>tbody>tr:nth-child(odd)>th { 4 background-color: red; 5 } 6

application.html.erb

erb

1<!DOCTYPE html> 2<html> 3 <head> 4 <title>OctansLocal</title> 5 <%= csrf_meta_tags %> 6 7 <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 8 <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 9 </head> 10..

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

application.html.erbのheadタグの中に、<%= stylesheet_link_tag 'order' %>を追加するといかがでしょうか。

投稿2019/01/04 01:46

psuke

総合スコア202

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

shimazu

2019/01/04 02:28 編集

以下のエラーが出ました。 Asset was not declared to be precompiled in production. Add `Rails.application.config.assets.precompile += %w( order.css )` to `config/initializers/assets.rb` and restart your server
shimazu

2019/01/04 02:32

エラーにあるように config/initializers/assets.rbに Rails.application.config.assets.precompile += %w( order.css ) を追加すれば無事反映されました。 ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問