技術

【Rails5.2】bootstrap4を追加する

投稿日:

こんにちは

今回はRails5にbootstrap4を追加したいと思います。

使うgemはこれ

bootstrap-rubygem

1.Gemfileにbootstrapを追加
gem 'bootstrap', '~> 4.1.3'

2.application.cssをaplication.scssに変更してbootstrapをimportする。
@import "bootstrap";

3.application.scssにかかれている、= requireと=require_treeを削除する。

4.Gemfileにjquery-railsを追加
gem 'jquery-rails'

5.application.jsに以下を追加

//= require jquery3
//= require popper
//= require bootstrap-sprockets

導入は以上なのですが、ページを開くとAutoprefixer doesn’t support Node v4.8.2.というエラーが出るときがあります。
その時は下記のGemを追加してください。
gem 'mini_racer'

私の場合はこれで解決しました。

-技術

執筆者:


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

関連記事

[Xcode] SDK Version Issue – This app was built with the iOS 12.0 SDK. Starting March 2019, all iOS apps submitted to the App Store must be built with the iOS 12.1 SDK or later, included in Xcode 10.1 or later.

こんにちは。たなかです。 2019年、ブログ初更新になります。今年もよろしくお願 …

no image

HTMLエンティティを探すならHTML Arrowsがオススメ!

こんにちは htmlエンティティっていうのを聞いたことがありますか? アンパサン …

[ Ionic ] A problem occurred evaluating project ‘:app’. > Failed to apply plugin [class ‘com.google.gms.googleservices.GoogleServicesPlugin’] > For input string: “+”

こんにちは。たなかです。 相変わらずモバイルアプリ開発やっています。 先日、Io …

no image

ng-ifのelse句でコンポーネントのプロパティと名前重複

こんにちは、コーテッグのこやまです。 Angularを触っていたら、コンポーネン …

no image

[Rails]if文とcontent_for

こんばんは content_for便利ですよね。 今回はcontent_forと …