Question

I'm trying to install the bootstrap-sass gem on my Rails 3.2 app, but encounter this error when I call compass install bootstrap :

No such framework: "bootstrap"

I have the gem installed in my Gemfile:

gem 'compass', '~> 0.12.2'
group :assets do
  ...
  gem 'sass-rails', '~> 3.2.4'
  gem 'compass-rails', '~> 1.0.3'
  gem 'bootstrap-sass', '~> 2.1.1.0'
end

I've put in the import statement to my application.css.scss file:

@import "bootstrap";

I've required bootstrap in my application.js:

//= require jquery
//= require jquery_ujs
//= require bootstrap
...

and I've required bootstrap-sass in my config.ru file:

require 'bootstrap-sass'

require ::File.expand_path('../config/environment',  __FILE__)

run MYAPP::Application

Anyone have any idea what the problem could be, or encountered the same problem?

Here's the git for bootstrap-sass: https://github.com/thomas-mcdonald/bootstrap-sass.git

Was it helpful?

Solution 2

Figured it out...

So to get the install to work, I had to call bundle exec compass install bootstrap. This executes compass install bootstrap in the context of the bundle, which includes all the gems. However, this gave rise to some more problems.

The install wrote several new bootstrap javascript files to my assets/javascripts directory. In Rails 3.2, these are automatically loaded by the asset pipeline, but in the wrong order, so in my browser console, I was getting error messages for a missing constructor and calling 'popover' on an undefined object. After digging around, the solution was just to delete all the newly generated javascript files, as they are already included by having //= require bootstrap in application.js.

OTHER TIPS

The bootstrap-sass is not well documented, it take me some time to make a workaround. Forget about the compass. gemfile:

gem 'bootstrap-sass', '~> 2.1.1.0'
gem 'bootswatch-rails'

use bootswatch-rails gem can quickly change your themes

in assets/stylessheets, create a your_own_sytlesheet.css.scss

    @import "bootswatch/cerulean/variables";

// Then bootstrap itself
@import "bootstrap";

// Bootstrap body padding for fixed navbar
body { padding-top: 60px; }

// Responsive styles go here in case you want them
@import "bootstrap-responsive";

// And finally bootswatch style itself
@import "bootswatch/cerulean/bootswatch";

// Whatever application styles you have go last
//@import "base";

you can change themes easily by replacing cerulean with other names.

At least it works for me now.

You don't need gem for this. Just copy bootstrap libs (scss & js files) to your assets. Make sure that no more text in your application.css.scss before @import 'bootstrap'; And don't need edit config.ru file

Also look into you page code. What is displaying in application.css ? Have you user in your controller inheritance of ApplicationController?

In your gem file try keeping bootstrap gem outside asset.

source 'https://rubygems.org'

gem 'rails', '3.2.8'
gem 'bootstrap-sass', '2.1.1'

And then run command

$ bundle install.

Then check and ensure that bootstrap is installed using command.

$bundle list

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top