Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Bootstrap 3 RC with Rails 4

I'm trying to migrate from Bootstrap 2, to version 3 RC1 in a Rails 4 project.

Initially I used bootstrap-sass gem 2.3.2 and everything worked smoothly.

How can i add Boostrap 3 to my project now? I can't find any gem already converted to SASS and the official documentation tells to compile it into CSS from LESS.

I'm fairly new to all of this so i'm really getting confused here, any help?

UPDATE Seems like the gem i was using in the first place has been finally updated: https://github.com/twbs/bootstrap-sass

like image 265
pastullo Avatar asked Aug 03 '13 11:08

pastullo


3 Answers

try using https://github.com/anjlab/bootstrap-rails

by adding the following to your Gemfile:

gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails',
                          :github => 'anjlab/bootstrap-rails',
                          :branch => '3.0.0'

In your application.js add the following:

//= require twitter/bootstrap

In your application.css add the following before anything else:

 *= require twitter/bootstrap
like image 143
ShenoudaB Avatar answered Oct 21 '22 00:10

ShenoudaB


There is already release candidate that you can use, add to GemFile:

gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass'

Additionally if you upgrade from bootstrap 2 then you have to remove previous gem before.

like image 22
TSr Avatar answered Oct 20 '22 22:10

TSr


I tried the solution suggested by ShenoudaB and got it to work just fine. Things I needed to change from the previous version were:

  • In your application.css.scss file, make sure you are referencing twitter/bootstrap instead of just bootstrap.
  • I also needed to add an @import "twitter/bootstrap"; line to my css. This may be redundant with the above tip, but once I added it, it worked fine.
  • In your application.js file, you should reference twitter/bootstrap in your //=require statement.

I also noticed that some of the styles changed. Check the new documentation and make sure your class names match the new ones.

That's all I did and it worked for me. Good luck getting your app to work!

like image 20
Andrew Patzer Avatar answered Oct 20 '22 23:10

Andrew Patzer