创建项目
rails new BootstrapProject
创建模型
rails g scaffold xxx --skip-stylesheets
运行迁移
rake db:migrate
--------- 如果项目和模型都已经建立好了并已经运行了迁移,那么可以省略以上步骤,直接进入下面的流程 ---------
在Gemfile中添加bootstrap,这里使用twitter-bootstrap-rails
gem 'twitter-bootstrap-rails'
gem 'therubyracer'
gem 'less-rails'
bundle
bundle install
安装bootstrap
rails g bootstrap:install
在模型上运用bootstrap
rails g bootstrap:themed xxx -f
注:xxx可以是任意的模型,例如模型名称是Article,那么这里的语句就是:
rails g bootstrap:themed Articles
还要在application.js中加上引用,否则bootstrap的一些按钮会失效:
//= require jquery
//= require twitter/bootstrap
Enjoy it~