rails 5.0 安裝部署
1剧罩、新項(xiàng)目創(chuàng)建
rails new railsproject --skip-bundle (因?yàn)間fw的緣故)所以加--skip跳過(guò)bundle指煎,等項(xiàng)目創(chuàng)建成功之后進(jìn)入railsproject目錄下打開(kāi)gemfile 修改為 source'https://ruby.taobao.org'跟啤,然后進(jìn)行bundle install
2闸迷、給項(xiàng)目安裝bootstrap棉胀,使用的bootstrap-sass這個(gè)套件理张。
2.1系瓢、修改 Gemfile,在group :development, :test do前一行加入gem 'bootstrap-sass'
2.2揖闸、執(zhí)行bundle install
3揍堕、使項(xiàng)目使用 Bootstrap
3.1 修改app/assets/stylesheets/application.css 文件為application.scss
3.2 然后在application.scss文件添加如下兩行
@import"bootstrap-sprockets";
@import"bootstrap";
4、使用bootstrap樣式
4.1新建app/views/common 文件夾
4.2 在common文件夾下面新建_navbar.html.erb
4.3 在common文件夾下面新建_footer.html.erb
4.4 修改全域 HTML 樣式 application.html.erb
4.5 新增一個(gè)控制器rails g controller welcome
4.6 新增一個(gè)歡迎頁(yè)面 welcome/index.html.erb
4.7 將首頁(yè)指到 welcome 下的 index.html.erb 頁(yè)面
5汤纸、制作提示信息
5.1將 Boostrap 的 js 提示套件 bootstrap/alert “掛”進(jìn)項(xiàng)目里面鹤啡,在app/assets/app/assets/javascripts/application.jsrequre_tree上加入
//= require bootstrap/alert/
5.2 . 新增 app/views/common/_flashes.html.erb
5.3 新增 app/helpers/flashes_helper.rb
5.4 在 application.html.erb 內(nèi)加入 flash 這個(gè) partial,在<%= yield %>前加入<%= render "common/flashes" %>