Stock Bootstrap 3 Configuration

Rinse and repeat cycle for adding Bootstrap 3.0 to a Rails 3.2 or 4.0 project.

Add the following to your Gemfile where appropriate:

Gemfile
1
2
3
4
5
6
7
8
9
10
#...

gem 'bootstrap-sass'

group :development do
    #...
    gem 'rails_layout' # Used for generating the initial layout
end

#...

Execute the following in your project directory:

Shell Commands
1
2
3
bundle install

rails generate layout bootstrap3 --force

A really handy form handler that throws away the standard rails generators and boilerplate HTML is bootstrap_form.

Add this to your Gemfile:

Gemfile
1
2
3
4
5
#...

gem 'bootstrap_form'

#...

Next, edit your _form views to look like the following (note the replacement of form_for with bootstrap_form_for):

_form.html.erb
1
2
3
4
5
6
<%= bootstrap_form_for(@user) do |f| %>
  <%= f.email_field :email %>
  <%= f.password_field :password %>
  <%= f.check_box :remember_me %>
  <%= f.submit %>
<% end %>

bootstrap_form will generate all of the boilerplate HTML and make a clean looking form. Reference the github page for further customizations.