Thomas Blumenfeld


960 Experience
9 Lessons Completed
0 Questions Solved


Posted in Issue with bootstrap sprockets in application.js

Yeah, even better if you're using a more recent version of bootstrap.

In terms of messaging/social purpose I would suggest to develop those features by yourself. There are not too complicated and it is better to control your features than to force yourself to use a library that will probably end up causing you more troubles than solutions.

It is based on my personal experience.

Must be because you have a controller filter that redirects to a /login route.

But you don't have any /login route in your route.rb file.

Are you trying to implement authentication but are new to rails ?

You should create two layouts :

One 'main.html.erb' et one 'dashboard.html.erb'

And then specify on your controllers which layout they should use.

main_controller.rb should have layout 'main'
dashboard_controller.rb should have layout 'dashboard'

Those two controllers should inherit from ApplicationController. And then each controller in your app should inherit from either MainController or DashboardController.

Then you should have two css and js application files.

It depends if you use sprockets or webpacker but either way each layout should have its own application pack (webpacker) or manifest file (sprockets).

Like main.scss and main.js file on one side, and dashboard.scss and dashboard.js on the other.

Posted in Issue with bootstrap sprockets in application.js

Looks like you have a version issue here.

The gem version of bootstrap-sass specifies an import with

//= require bootstrap-sprockets

Whereas your version seems to be the It specifies an import like this :

We have a helper that includes all available javascripts:

// Loads all Bootstrap javascripts
//= require bootstrap

You can also load individual modules, provided you sort out any related dependencies.

//= require bootstrap-scrollspy
//= require bootstrap-modal
//= require bootstrap-dropdown

You should fix your gem version in your gemfile to and use the correct way to call the lib.

Posted in How do I integrate a bootstrap theme with rails 6 ?


You should manage all your assets with webpacker.

For bootstrap, you should use the bootsrap npm lib bootstrap-sass by running the command

yarn add bootstrap-sass

Then you should import it in your main application.js file (your webpacker 'pack')

For bootstrap javascript modules :

/* Bootstrap modules */
import "bootstrap-sass/assets/javascripts/bootstrap/dropdown";
import "bootstrap-sass/assets/javascripts/bootstrap/modal";
import "bootstrap-sass/assets/javascripts/bootstrap/tooltip";
import "bootstrap-sass/assets/javascripts/bootstrap/popover";

For your stylesheets you can import the main stylesheet file in this application.js file :

/* Import stylesheets */
import "../stylesheets/style";

And your main style.scss file should import bootstrap from this lib.

// Twitter Boostrap
@import "~bootstrap-sass/assets/stylesheets/bootstrap";

You can then import all your theme stylesheets below.

Posted in What is the purpose of node_modules folder in rails 6?

node_modules is not rails specific actually.

Since rails 6 is using webpack as the assets manager instead of sprockets, you get this node_modules folder with all dependencies of the libs specified in you package.json file.

It is created when using the npm or yarn command to download and host in your project all the javascript libraries required by your project.