安裝 Bootstrap CSS

安裝 Gem: bootstrap-sass

修改 Gemfile

# Use Puma as the app server
gem "puma", "~> 3.0"
gem "bootstrap-sass", "~> 3.3.7" # <--- 加入這一行
# Use SCSS for stylesheets
gem "sass-rails", "~> 5.0"

然後 bundle install

設定 bootstrap

application.css 改成 app/assets/stylesheets/application.scss

mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss

接著修改 app/assets/stylesheets/application.scss,整個文件替換成下面的內容:

@import "bootstrap-sprockets";
@import "bootstrap";

即可。

修改 app/assets/javascripts/application.js

加入 //= require bootstrap-sprocketsapp/assets/javascripts/application.js

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

results matching ""

    No results matching ""