Q&A
bootstrap 4の実装
現在Rails5を使って、簡単なページを作り、それにbootstrap4を適用しようとしていますが、githubのreadmeに従って実装しています。
Viewの表示画面でRuntimeError
RuntimeError in StaticPages#home Showing /home/vagrant/environment/my_app/app/views/layouts/application.html.erb where line #7 raised: Autoprefixer doesn’t support Node v0.10.48. Update it. Extracted source (around line #7): 5 6 7 8 9 10 <%= csrf_meta_tags %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> </head> Rails.root: /home/vagrant/environment/my_app Application Trace | Framework Trace | Full Trace app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb___2380894952555606829_47408661428280' Request Parameters: None Toggle session dump Toggle env dump Response Headers: None
以下、現在のコード
gemfile
1source 'https://rubygems.org' 2 3gem 'rails', '~> 5.1.6' 4gem 'sqlite3' 5gem 'puma', '~> 3.7' 6gem 'bootstrap', '~> 4.1.3' 7gem 'sass-rails', '~> 5.0' 8gem 'uglifier', '>= 1.3.0' 9gem 'coffee-rails', '~> 4.2' 10gem 'turbolinks', '~> 5' 11gem 'jbuilder', '~> 2.5' 12gem 'sprockets-rails', '3.2.1' 13gem 'jquery-rails', '4.3.1' 14 15 16group :development, :test do 17 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 18 gem 'capybara', '~> 2.13' 19 gem 'selenium-webdriver' 20end 21 22group :development do 23 gem 'web-console', '>= 3.3.0' 24 gem 'listen', '>= 3.0.5', '< 3.2' 25 gem 'spring' 26 gem 'spring-watcher-listen', '~> 2.0.0' 27end 28 29group :test do 30 gem 'rails-controller-testing', '1.0.2' 31 gem 'minitest', '5.10.3' 32 gem 'minitest-reporters', '1.1.14' 33 gem 'guard', '2.13.0' 34 gem 'guard-minitest', '2.4.4' 35end 36 37 38# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 39gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 40
assets/stylesheets/application.scss
// Custom bootstrap variables must be set or imported *before* bootstrap. @import "bootstrap";
assets/javascripts/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 turbolinks //= require_tree . //= require jquery3 //= require popper //= require bootstrap-sprockets
views/layouts/application.html.erb
<!DOCTYPE html> <html> <head> <title>MyApp</title> <%= csrf_meta_tags %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> </head> <body> <%= yield %> </body> </html>
試したこと
application.scssファイルを既存のapplication.cssに上書きするパターンと、しないパターンを試してみましたが、効果なし。
aplication.html.erbのlink_tagを'aplication'のみにしてみましたが、効果ありませんでした。