If you are looking for simplest workaround for installing the SASS based Twitter Bootstrap library in your rails app; then you are in the right place. I have written the steps I followed to get my app working with Bootstrap.
The main twitter guideline is a bit lengthy and if you already have some idea about how this library works; this post is more than enough to install.
bootstrap-sass is a Sass-powered version of Bootstrap, ready to drop right into your Sass powered applications. Asset pipeline makes it easy to get
bootstrap-sass working in Rails.
# in Gemfile gem 'bootstrap-sass', '~> 3.3.5' gem 'sass-rails', '>= 3.2'
you know how to install the gems;🙂
$ bundle install
now you gonna use SASS’s @import technique to import the library styles in your application’s stylesheet;
@import "bootstrap-sprockets"; @import "bootstrap"; // make sure you import "bootstrap-sprockets" in the first place; other libraries gonna depend on this
to rename the
stylesheets/application.css to stylesheets/application.scss
$ mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss
If you follow the https://github.com/twbs/bootstrap-sass you might encounter the statement
remove all the
*= require_tree .statements from the sass file. Instead, use
@importto import Sass files.
Do not use
*= requirein Sass or your other stylesheets will not be able to access the Bootstrap mixins or variables.
The statement above says that you cannot include/use Bootstrap mixins using traditional `sprocket`’s notations viz. *=require ; However it doesnot mean that you should not use them to require other `.css/.scss` files you create for your app.
Requiring JS files
//= require jquery //= require bootstrap-sprockets
bootstrap should not both be included in
dropdown.js, for example), while