Last Updated: June 21, 2017
·
669
· rebagliatte

Rails Assets + Twitter Bootstrap 3 + Simple Form = <3

1. Get your gemfile ready

Add simple form:

gem 'simple_form', '~> 3.1.0'

Add an additional source for rails assets:

source 'https://rails-assets.org'

Add any bower package you might need, prepending the package name with "rails-assets" like this:

gem 'rails-assets-bootstrap'
gem 'rails-assets-jquery'
gem 'rails-assets-jquery-ujs'

2. Get everything installed

On your console:

bundle
rails generate simple_form:install --bootstrap

3. Call your assets

On application.js:

//= require jquery
//= require jquery-ujs/rails
//= require bootstrap
//= require_tree .

On application.css:

/*
 *= require bootstrap
 *= require_tree .
 *= require_self
 */

4. Generate some resources to test this out and migrate

rails g scaffold posts title:string body:text
bundle exec rake db:migrate

5. Use bootstrap classes

6. All set!!!