前提・実現したいこと
以前のようにBootstrap4が適用された状態にしたいです。
Railsで初めてのオリジナルアプリを製作中です。
開発も後半に差し掛かってきたところ、突然開発環境でBootstrapが全く読み込まれなくなりました。
一部や1ページだけではなく全て適用されず、殺風景になってしまいました。
また、表示されていた画像も表示されません。
発生している問題・エラーメッセージ
エラーメッセージなどはなく、殺風景なページが表示されるだけです。
ここまで問題なく読み込まれていていましたが、フォームで画像を扱いたいと考え、gem 'carrierwave'
を導入してみました(参考にしたサイト)。
この通りいじってみると、Bootstrapが読み込まれなくなっていたということです。
デバッグのために画像を扱うに祭して追加した処理(carrierwaveの削除→bundle installを含む)を全部巻き戻してみましたが状況は改善しませんでした。
1日格闘しましたが全く手がかりが掴めず...
お手数ですがどなたかお力を貸していただけないでしょうか?
該当のソースコード
application.html.erb
<!DOCTYPE html> <html> <head> <title>NonsmokingApp</title> <%= csrf_meta_tags %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> <%= render "layouts/shim" %> </head> <body> <%= render "layouts/header" %> <div class="container"> <% flash.each do |message_type, message| %> <div class="alert alert-<%= message_type %>"><%= message %></div> <% end %> <%= yield %> <%= render "layouts/footer" %> <%= debug(params) if Rails.env.development? %> </div> </body> </html>
application.scss
@import "bootstrap"; /* * 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, * vendor/assets/stylesheets, or vendor/assets/stylesheets of plugins, if any, * 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 styles defined in the other CSS/SCSS * files in this directory. It is generally better to create a new file per * style scope. * *= require_tree . *= require_self */
application.js
// This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's // vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. JavaScript code in this file should be added after the last require_* statement. // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // //= require rails-ujs //= require activestorage //= require turbolinks //= require jquery3 //= require popper //= require bootstrap-sprockets (function($) { "use strict"; // Start of use strict // Smooth scrolling using jQuery easing $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() { if (location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); if (target.length) { $('html, body').animate({ scrollTop: (target.offset().top - 54) }, 1000, "easeInOutExpo"); return false; } } }); // Closes responsive menu when a scroll trigger link is clicked $('.js-scroll-trigger').click(function() { $('.navbar-collapse').collapse('hide'); }); // Activate scrollspy to add active class to navbar items on scroll $('body').scrollspy({ target: '#mainNav', offset: 56 }); // Collapse Navbar var navbarCollapse = function() { if ($("#mainNav").offset().top > 100) { $("#mainNav").addClass("navbar-shrink"); } else { $("#mainNav").removeClass("navbar-shrink"); } }; // Collapse now if page is not at top navbarCollapse(); // Collapse the navbar when page is scrolled $(window).scroll(navbarCollapse); })(jQuery); // End of use strict
Gemfile
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.6.3' gem 'rails', '~> 5.2.3' gem 'bcrypt', '3.1.12' gem 'will_paginate', '3.1.6' gem 'bootstrap-will_paginate', '1.0.0' gem 'puma', '~> 3.11' gem 'bootstrap', '~> 4.1.1' gem 'jquery-rails' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.2' gem 'turbolinks', '~> 5' gem 'jbuilder', '~> 2.5' gem 'bootsnap', '>= 1.1.0', require: false #carrierwaveは一旦消しました。 group :development, :test do gem 'sqlite3', '~> 1.3.6' gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do gem 'better_errors' gem 'binding_of_caller' gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end group :production do gem 'pg', '0.20.0' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
必要なファイル等がありましたら追加しますので教えて頂けますと幸いです。
以上、よろしくお願いいたします。
試したこと
・画像を扱える機能導入手順の戻り
・rails serverの再起動
・sprockets-rails が v2.3.2以上であることの確認
・適用されない時のチェックポイントを確認するサイトでの各項目の確認
補足情報(FW/ツールのバージョンなど)
・ macOS
・RubyMineで開発中
回答1件
あなたの回答
tips
プレビュー