前提・実現したいこと
簡単な画像投稿アプリができたのでHerokuにデプロイしました。
Bootstrapでデザインしたのですがglyphiconがローカルで反映したのがHerokuで反映しなかったので、
自分で調べ、アセットコンパイル関係であると判明し、アイコンが反映するところまでは解決致しました。
で、最後、RSpecをクリアしたいのですができません。システムテストがパスの関係でエラーになります。
※glyphiconは反映済みで、Capybaraの画面の挙動上はテストが通りますがターミナルでエラーが出ます。
#バージョン情報
Bootstrap 3.4.1
Ruby 2.6.5
Rails 5.2.4.2
#発生している問題・エラーメッセージ
RSpecのエラーメッセージが以下になります。
自分でhttps://www.azusa.me/blog/?p=2016など検索したところ
bootstrap.cssの266行目以降〜@font-faceを上書きする必要があるようなのですが、
①application.cssに上書きのコードを記述したものの反映しない。同じエラーが出ます。
②bootstrap.cssの@font-faceを直接上書きしたもののコンパイルすると元に戻ります。
Failure/Error: raise ActionController::RoutingError, "No route matches [#{env['REQUEST_METHOD']}] #{env['PATH_INFO'].inspect}" ActionController::RoutingError: No route matches [GET] "/fonts/glyphicons-halflings-regular.woff2"
#該当のソースコード
Bootstrap
1@font-face { 2 font-family: "Glyphicons Halflings"; 3 src: url("../fonts/glyphicons-halflings-regular.eot"); 4 src: url("../fonts/glyphicons-halflings-regular.eot?#iefix") format("embedded-opentype"), url("../fonts/glyphicons-halflings-regular.woff2") format("woff2"), url("../fonts/glyphicons-halflings-regular.woff") format("woff"), url("../fonts/glyphicons-halflings-regular.ttf") format("truetype"), url("../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular") format("svg"); 5}
を
application
1@font-face { 2 font-family: "Glyphicons Halflings"; 3 src: url("/assets/glyphicons-halflings-regular.eot"); 4 src: url("/assets/glyphicons-halflings-regular.eot?#iefix") format("embedded-opentype"), url("/assets/glyphicons-halflings-regular.woff2") format("woff2"), url("/assets/glyphicons-halflings-regular.woff") format("woff"), url("/assets/glyphicons-halflings-regular.ttf") format("truetype"), url("/assets/glyphicons-halflings-regular.svg#glyphicons_halflingsregular") format("svg"); 5}
で上書きできたらと思いますが、上書きできない状況です。
#試したこと
glyphiconをアセットコンパイルしたとき、fontsディレクトリをassetsにコピーし、パスを通したので、
同じようにassetsのstylesheetにbootstrap_and_overrides.css
みたいな上書き用のファイルを作り、
パスを設定することを試みましたが、glyphiconも反映しないような状況になりましたのでやめました。
Rails.application.config.assets.paths << Rails.root.join('fonts') Rails.application.config.assets.precompile += %w(.svg .eot .woff .woff2 .ttf)
application.cssのときと同じように上書きしようと思いましたがダメでした。
@font-face { font-family: "Glyphicons Halflings"; src: url("/assets/glyphicons-halflings-regular.eot"); src: url("/assets/glyphicons-halflings-regular.eot?#iefix") format("embedded-opentype"), url("/assets/glyphicons-halflings-regular.woff2") format("woff2"), url("/assets/glyphicons-halflings-regular.woff") format("woff"), url("/assets/glyphicons-halflings-regular.ttf") format("truetype"), url("/assets/glyphicons-halflings-regular.svg#glyphicons_halflingsregular") format("svg"); }
お忙しいところ大変恐縮ですが、お力添えいただけたら幸甚です。何卒よろしくお願い申し上げます。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2020/04/17 10:09