Rails: Bootstrap dropdown menu not working

后端 未结 6 1350
逝去的感伤
逝去的感伤 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 15:15

    In modern version of the book (rails 6+) this is what i've done to make it work:

    In app/javascript/packs/application.js change the order of

    require("jquery");
    import "bootstrap";
    

    to be before turbolinks - so final implementation of application.js looks like:

    require("jquery");
    import "bootstrap";
    require("@rails/ujs").start();
    require("turbolinks").start();
    require("@rails/activestorage").start();
    require("channels");
    

    Book shows to add jquery & bootstrap at the end after turbolinks - what in my opinion causes the problem. Thanks!

提交回复
热议问题