2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ドロップダウン機能を有効にするため、Railsのapplication.jsファイルを通して、Bootstrapに同梱されているJavaScriptライブラリとjQueryを読み込むようアセットパイプラインに指示

Last updated at Posted at 2019-12-24

railsチュートリアルで、Accountをクリックしてプルダウンメニュー出すために、少し手こずったのでメモ。

実装させたい機能⬇️
fullsizeoutput_b8c.jpeg
application.jsに2つのライブラリを追加。

application.js
//= require rails-ujs
//= require jquery     ⇦追加
//= require bootstrap   ⇦追加
//= require turbolinks
//= require_tree .

fullsizeoutput_b8b.jpeg
と、Sprockets::FileNotFoundエラーが出る。

Gemfileにgemを追加。

gem 'rails', '~> 5.2.4', '>= 5.2.4.1'
gem 'bcrypt',         '3.1.12'
gem 'bootstrap-sass', '3.3.7'
gem 'jquery-rails', '~> 4.3', '>= 4.3.1'   ⇦追加

追加後bundle installとrails sでサーバー再起動。
fullsizeoutput_b8d.jpeg
無事に、機能実装完了。

2
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?