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

前端 未结 4 886
不思量自难忘°
不思量自难忘° 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: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.

提交回复
热议问题