Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing https://github.com/twbs/bootstrap-rubygem on rails 6 alpha

How do you install the bootstrap gem (https://github.com/twbs/bootstrap-rubygem) on rails 6?

The bootstrap README asks us to add things to application.js but rails 6 doesn't seem to have an application.js in the usual place.

[ Rails 6.0.0.alpha ] bundle exec rails new noname --edge --database=postgresql --webpacker=react

like image 933
american-ninja-warrior Avatar asked Feb 12 '26 06:02

american-ninja-warrior


2 Answers

If you use webpacker, you may want to use the npm package of bootstrap

yarn add [email protected] popper.js

and

# app/javascript/packs/application.js
import 'bootstrap/dist/js/bootstrap';

and inside stylesheets.scss

@import '~bootstrap/scss/bootstrap';

Please look at the complete steps here: https://medium.com/@coorasse/goodbye-sprockets-welcome-webpacker-3-0-ff877fb8fa79

like image 144
coorasse Avatar answered Feb 15 '26 10:02

coorasse


This is the most basic solution for me:

Install bootstrap, jquery and popper.js with yarn:

$ yarn add bootstrap
$ yarn add jquery
$ yarn add popper.js

Then require bootstrap JS and CSS in app/javascript/packs/application.js:

require('bootstrap')
require('bootstrap/dist/css/bootstrap.min.css')

Note: If you need to use SCSS to customize Bootstrap then this solution is not proper for you. Use @coorasse's solution above.

like image 27
ismailarilik Avatar answered Feb 15 '26 11:02

ismailarilik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!