Menu

Bootstrap on Rails (rbenv way) in Debian Stretch.

Following my last post, Ruby on Rails (rbenv way) in Debian Stretch, I'm going to share a few notes that I got at hand when it comes to do early first steps in a Rails project.
As I was learning, basically, I didn't want to look again and again the same things, every time I was following a new tutorial and started up a new project in order to have bootstrap environment ready.

Adding boostrap

Edit the gemfile file to declare the new gems to provide bootstrap, and paste the following two lines:

gem 'bootstrap-sass', '~> 3.2.0'
gem 'autoprefixer-rails'

 
Now, in the console, ask bundler to become aware of the new gems required and let it install them along with eventual dependencies (since I'm using rbenv-gemset, I issue the command like this):

bundle install --path .gems

 
Now we need to ammend environment css config files in order to load available boostrap stuff. So, rename app/assets/stylesheets/application.css to app/assets/stylesheets/application.css.sass and edit it adding these two lines:

@import "bootstrap-sprockets"
@import "bootstrap"

 
And we do analog thing to javascript config files so jquery stuff for bootstrap becomes useable in the framework. So edit app/assets/javascripts/application.js and add bootstrap-sprockets BETWEEN jquery declarations and require_tree declarations

//= require jquery
//= require jquery_ujs
//= require turbolinks

//= require bootstrap-sprockets

//= require_tree .

 
Done. Now you should be able to use bootstrap in your views!

comments powered by Disqus