Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install bootstrap gem or yarn add bootstrap for rails 5.1 or both

After getting a project setup in rails 5.1 with --webpack=react option should I install the bootstrap gem? or use yarn add bootstrap? Or would I need both if I'm using rails and react components throughout a project?

Also, are there pros and cons of either method?

like image 448
Luke Popwell Avatar asked Jul 24 '17 19:07

Luke Popwell


1 Answers

It depends on where you want to use Bootstrap.

In the case you need it, in a app/views/*/*.html.erb for instance, you would need the gem, and require it in the Rails assets pipeline in the app/assets/stylesheets/application.scss and same for JavaScript file.

But as you mentioned you created your Rails application with --webpack=react, I guess you'd like to use Bootstrap in your client side application, so the app/javascript folder and not the Rails assets (app/assets). In this case you will have to install it using yarn.

You have to see the app/assets as the "old way", or the non-javascript framework way (which isn't fully true as you have some gems to install React or AngularJs etc...), and you should see app/javascript the new way, with webpacker, so using a JavaScript framework and being an app 100% JavaScript (while in the assets you'll use some .erb files).

like image 140
ZedTuX Avatar answered Nov 18 '22 07:11

ZedTuX