Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Bootstrap 3 on Rails App

I'm trying to install Bootstrap 3.0 on my Rails app. I recently finished Michael Hartl's tutorial and am now trying to build my own system using this new version of Bootstrap, but I have a few questions that I'm not sure about.

My system specs:

  • OS X Mountain Lion on MBP
  • Rails 4.0
  • Ruby 2.0

Questions I have:

  1. What is the best gem to use in my Gemfile? I have found a few of them.
  2. What do I import on my custom.css.scss? I read somewhere that it's different from 2.3.2.
  3. Is there anything else I have to do to get Bootstrap to work, or are the remaining steps identical to the ones I followed for Bootstrap 2.3.2?

Edit

Here is what the bootstrap-rails project on GitHub first says to do:

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

Then it says to do:

gem 'anjlab-bootstrap-rails', '>= 3.0.0.0', :require => 'bootstrap-rails' 

Do they do the same thing, or do you have to do them both?

like image 461
megashigger Avatar asked Aug 22 '13 03:08

megashigger


People also ask

How do I add bootstrap to angular app?

Adding bootstrap using the angular. Open the file and perform the following commands, node_modules/bootstrap/dist/css/bootstrap. css in the projects->architect->build->styles array, node_modules/bootstrap/dist/js/bootstrap. js in the projects->architect->build->scripts array, node_modules/bootstrap/dist/js/bootstrap.


1 Answers

Actually you don't need gem for this, here is the step to install Bootstrap 3 in RoR

  • Download Bootstrap

  • Copy:

    bootstrap-dist/css/bootstrap.css and bootstrap-dist/css/bootstrap.min.css

    To: vendor/assets/stylesheets

  • Copy:

    bootstrap-dist/js/bootstrap.js and bootstrap-dist/js/bootstrap.min.js

    To: vendor/assets/javascripts

  • Update: app/assets/stylesheets/application.css by adding:

    *= require bootstrap.min 
  • Update: app/assets/javascripts/application.jsby adding:

    //= require bootstrap.min 

With this you can update bootstrap any time you want, don't need to wait gem to be updated. Also with this approach assets pipeline will use minified versions in production.

like image 134
hawk Avatar answered Oct 10 '22 16:10

hawk