Rollen Holt
Rollen Holt

Reputation: 517

the "bootstrap-sass" doesn't work with rails 3.2.2

I create a new rails project,and add

gem 'bootstrap-sass'

to my Gemfile, then I run bundle install and every things going good. then I add:

/*
*= require bootstrap
*/

in my application.css file, and I write a test,but it doesn't. and I also try add`@import "bootstrap"; in my hello.css.scss file .but it also doesn't work.

Upvotes: 1

Views: 11721

Answers (4)

samuelkobe
samuelkobe

Reputation: 556

Remove all the comments at the top of the application.css and rename application.css to either application.sass or application.css.scss depending on how you want to do your css'ing Then add:

@import 'bootstrap'

This should allow you to start using bootstrap, providing you have indeed included the bootstrap-sass gem correctly and ran bundle install afterwards.

Upvotes: 1

8bithero
8bithero

Reputation: 1609

Probably a little late to the party, but just in case anyone else stumbles across the question...

This was a small gotcha I Solved by adding @import "bootstrap"; to the top of my application.css file, the renamed the file to application.css.scss

Hope this helps.

Upvotes: 5

Tim Knight
Tim Knight

Reputation: 8356

Rollen,

You seem to be mostly there. Sass is in Rails 3.1 by default so you won't need to do anything specific for that. After you add the gem to your Gemfile and do a bundle install your issue is in the application.css file. Typically when using Sass I'd just suggest that you remove the manifest code (all the commenting at the top) from the application.css and rename the application.css to application.css.scss (removing Sprockets from the CSS file). Then add:

@import 'bootstrap'

to the very top of it. That should solve it for you. You'll need to manually add each CSS file you'll want to load into the application.css.scss file since sprockets is gone, but that's typically a good idea anyway since load order in CSS is important for the cascade.

If you want to add the JavaScript features to the framework (which you likely will want to) you'll also want to add

//= require bootstrap

Just above the call to //= require_tree . within app/assets/javascripts/application.js.

Upvotes: 14

rajibchowdhury
rajibchowdhury

Reputation: 5544

https://github.com/rails/sass-rails needs to be there in your Gemfile.

gem 'sass-rails', '~> 3.1'
gem 'bootstrap-sass', '~> 2.0.1'

Upvotes: 2

Related Questions