the “bootstrap-sass” doesn't work with rails 3.2.2

前端 未结 4 899
不思量自难忘°
不思量自难忘° 2021-02-06 19:39

I create a new rails project,and add

gem \'bootstrap-sass\'

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

相关标签:
4条回答
  • 2021-02-06 20:22

    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.

    0 讨论(0)
  • 2021-02-06 20:23

    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.

    0 讨论(0)
  • 2021-02-06 20:29

    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.

    0 讨论(0)
  • 2021-02-06 20:33

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

    gem 'sass-rails', '~> 3.1'
    gem 'bootstrap-sass', '~> 2.0.1'
    
    0 讨论(0)
提交回复
热议问题