Ruby on Rails basics

Setting up HAML & Bootstrap

Jadam
Ruby on Rails::Basics
2 min readNov 8, 2014

--

Building off of the basic CRUD app I made from post on This is how you do basic CRUD we will be adding Twitter Bootstrap to it and swapping it over from Html to Haml. Twitter Bootstrap is a Haml is an Html abstraction language that I enjoy as it makes quickly scanning through my code base much easier.

Installing Bootstrap

Bootstrap is pretty quick and easy to get setup. First lets add the bootstrap-sass & autoprefixer gems to our Gemfile. Go ahead and clear out all those commented lines of code. Your file should look something similar to this:

Any time you add a gem to your Gemfile you will need to run the bundle command in your terminal:

We’ll jump over to our /assets directory to do the last two steps of the setup. In our css folder we’ll add these two lines of code at the bottom:
app/assets/stylesheets/application.css

We’ll also need to change the file name from application.css to application.css.scss

One more one liner and we’re done with basic Bootstrap Add //= require bootstrap-sprockets inside your application.js file.
app/assets/javascript/application.js

If you had your rails server running you will need to restart it.

Setting up Haml

Now over to Haml which is as simple as two things. Add the Haml gem to the Gemfile…

… and the second step is just to remember that whenever you create a new view file that instead of having it formated with an erb extension, al la filename.html.erb it ends instead with .haml filename.html.haml

There’s a lot you can do with Bootstrap and you really should dig through the documentation on their site. Should you have ran into any issues with setting up Bootstrap I suggest you check out their Github readme.

If the Haml walkthrough leaves you a bit curious you can read more with this short post Haml: form && function.

Available for Qs on Twitter: @MrJadaml

--

--

Jadam
Ruby on Rails::Basics

A chronic creative in Denver currently exploring street art in society though the @DenverStreetart project. All while trying to live a sustainable lifestyle.