Rails 4 + bootstrap set up assets

前端 未结 8 1533
春和景丽
春和景丽 2021-02-04 06:53

I am trying to setup bootstrap on Rails4 using bootstrap-sass and I am getting this famous error:

Sprockets::FileNotFound - couldn         


        
8条回答
  •  猫巷女王i
    2021-02-04 07:32

    Installing the Bootstrap Gem

    1.) Add the Bootstrap Gem:

    gem 'bootstrap-sass'
    

    2.) Understand The Application.css File app/assets/stylesheets/application.css

    Application.css takes all the other files in your /stylesheets directory and combines them for when you run your app.

    3.) Create a New SCSS File (app/assets/stylesheets/bootstrap_and_customization.css.scss)

    @import 'bootstrap';
    

    4.) Require Bootstrap's JavaScript

    ...
    //= require jquery
    //= require jquery_ujs
    //= require bootstrap <--
    //= require turbolinks
    //= require_tree .
    

    5.) Rails Assets

    group :production do
      gem 'rails_12factor'
    end
    

    6.) Bundle Install & Restart Server

    Thats should be it !

提交回复
热议问题