Rails: Bootstrap dropdown menu not working

后端 未结 6 1367
逝去的感伤
逝去的感伤 2021-01-24 14:18

I am quite new to Rails and have been following the tutorial by Michael Hartl. Everything has been going along really well until I got to the drop down menu, which was wasn\'t

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-24 14:55

    Using a later version of rails (5.2.3) I found that the instructions given in the book didn't work. The console warned me that jQuery needed to be installed, and by going to https://github.com/rails/jquery-rails I was able to find the instructions to get it up-and-running.

    Add to the Gemfile:

    gem 'jquery-rails'
    

    Add to application.js

    //= require jquery
    //= require bootstrap
    

    So that the whole Gemfile is

    //= require rails-ujs
    //= require activestorage
    //= require jquery
    //= require bootstrap
    //= require turbolinks
    //= require_tree .
    

提交回复
热议问题