[Ruby On Rails] Using Bootstrap

Bootstrap is very popular CSS framework. You can use the ‘bootstrap-sass’ gem to include Bootstrap in your project.

1. Installing bootstrap-sass Gem

In the “Gemfile“, add the ‘bootstrap-sass’ gem.

# bootstrap 
gem 'bootstrap-sass'

And then run the bundler.

> bundle install

2. Including Stylesheet

Add the “custom.css.scss” file to the “app/assets/stylesheets” folder and import the bootstrap.

@import "bootstrap";

3. Including JavaScript

Add the following code in the “application.js” file in the “app/assets/javascripts” folder.

//= require jquery 
//= require bootstrap 

4. Restarting the Server

To make changes effective, you need to restart the server.

> Ctrl + C

> rails server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s