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

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

新規登録して質問してみよう
ただいま回答率
85.48%
unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

Ruby on Rails

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

Bootstrap

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

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

Q&A

解決済

1回答

2804閲覧

couldn't find file 'bootstrap' with type 'text/css' に解決方法 Rails6

EleAco

総合スコア15

unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

Ruby on Rails

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

Bootstrap

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

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

0グッド

0クリップ

投稿2020/11/12 01:54

編集2020/11/12 02:34

ローカル環境では、不具合は起きなかったが本番環境にてエラーが発生…
###開発環境
rails6
EC2
unicorn

##エラーコード
重要なところ↓

ActionView::Template::Error (couldn't find file 'bootstrap/dist/css/bootstrap.min.css' with type 'text/css'

それ以外の全てのエラーコード↓

[1a62c96b-5fbf-4c87-9194-2e16f8249139] ActionView::Template::Error (couldn't find file 'bootstrap/dist/css/bootstrap.min.css' with type 'text/css' Checked in these paths: /var/www/photo_roke/app/assets/config /var/www/photo_roke/app/assets/images /var/www/photo_roke/app/assets/stylesheets /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/jquery-rails-4.4.0/vendor/assets/javascripts /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/actioncable-6.0.3.4/app/assets/javascripts /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activestorage-6.0.3.4/app/assets/javascripts /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/actionview-6.0.3.4/lib/assets/compiled /var/www/photo_roke/node_modules): [1a62c96b-5fbf-4c87-9194-2e16f8249139] 17: <%# ログアウト %> [1a62c96b-5fbf-4c87-9194-2e16f8249139] 18: <div class='logout-container'> [1a62c96b-5fbf-4c87-9194-2e16f8249139] 19: <div class='logout-btn'> [1a62c96b-5fbf-4c87-9194-2e16f8249139] 20: <%= link_to image_tag('exit.png', class: "logout-icon"), destroy_user_session_path, method: :delete %> [1a62c96b-5fbf-4c87-9194-2e16f8249139] 21: </div> [1a62c96b-5fbf-4c87-9194-2e16f8249139] 22: <span class='logout-text'>ログアウト</span> [1a62c96b-5fbf-4c87-9194-2e16f8249139] 23: </div> [1a62c96b-5fbf-4c87-9194-2e16f8249139] [1a62c96b-5fbf-4c87-9194-2e16f8249139] app/assets/stylesheets/application.css:2 [1a62c96b-5fbf-4c87-9194-2e16f8249139] app/views/shared/_post_header.html.erb:20 [1a62c96b-5fbf-4c87-9194-2e16f8249139] app/views/photos/index.html.erb:1 I, [2020-11-11T21:19:36.774031 #31800] INFO -- : [855c62cf-eb33-46af-9f02-625afd32a671] Started GET "/" for 209.17.96.10 at 2020-11-11 21:19:36 +0000 I, [2020-11-11T21:19:36.774705 #31800] INFO -- : [855c62cf-eb33-46af-9f02-625afd32a671] Processing by PhotosController#index as HTML I, [2020-11-11T21:19:36.775472 #31800] INFO -- : [855c62cf-eb33-46af-9f02-625afd32a671] Redirected to http://54.248.19.145:3000/homes/home I, [2020-11-11T21:19:36.775556 #31800] INFO -- : [855c62cf-eb33-46af-9f02-625afd32a671] Filter chain halted as :move_to_index rendered or redirected I, [2020-11-11T21:19:36.775650 #31800] INFO -- : [855c62cf-eb33-46af-9f02-625afd32a671] Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 336)

このようになっております
boostroapは使用せずに開発をしておりましたがファイルがないよと言われてしまいます…

##実行したこと
bower で Bootstrap を入れたあと "couldn't find file 'bootstrap' with type 'text/css'" が表示される
この記事を参考に
gimfileにこの二つを記述

gemfile

1gem 'therubyracer' 2gem 'less-rails'

##追加コード
application.cssの中身になります!

ruby

1/* 2*= require bootstrap/dist/css/bootstrap.min.css 3 * This is a manifest file that'll be compiled into application.css, which will include all the files 4 * listed below. 5 * 6 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's 7 * vendor/assets/stylesheets directory can be referenced here using a relative path. 8 * 9 * You're free to add application-wide styles to this file and they'll appear at the bottom of the 10 * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS 11 * files in this directory. Styles in this file should be added after the last require_* statement. 12 * It is generally better to create a new file per style scope. 13 * 14 *= require_tree . 15 *= require_self 16 */ 17 18 19

解決ができなかったため皆様方のお力をお借りしたいです!
よろしくお願いいたします!

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

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

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

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

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

maisumakun

2020/11/12 01:57

「boostroapは使用せずに開発をしておりましたが」と書いているのに、わざわざ@importでbootstrap関連のコードを追加しているのはなぜでしょうか?
EleAco

2020/11/12 01:59

maisumakunさん ご質問ありがとうございます! そのように記述すればエラーが解消すると書いてあったため思考停止で記述しておりました。。 ひとまずこちらを消してきます!!
EleAco

2020/11/12 02:27

maisumakunさん 質問内容の変更をいたしました! >「boostroapは使用せずに開発をしておりましたが」と書いているのに、わざわざ@importでbootstrap関連のコードを追加しているのはなぜでしょうか? こちら記述を消しましたがエラー文に変わりはありませんでした!
maisumakun

2020/11/12 02:32

app/assets/stylesheets/application.cssの中身はどのようになっていますか?
EleAco

2020/11/12 02:35

mausumakunさん コードを追加させていただきました! よろしくお願いいたします
guest

回答1

0

ベストアンサー

コメント内の= require bootstrap/dist/css/bootstrap.min.cssを消してください。

形式上はコメントですが、この行はSprocketsにとって意味を持ちます

投稿2020/11/12 02:37

maisumakun

総合スコア145186

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

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

EleAco

2020/11/12 03:06

maisumakunさんありがとうございました! 無事他のエラーが出ました!! また、よろしくお願いいたします!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問