此文根據(jù)如下鏈接撰寫
https://launchschool.com/blog/integrating-rails-and-bootstrap-part-1
首先必須安裝Ruby on Rails。
新建一個叫做**myforum**的Rails app(以下所有命令在iTerm中輸入):
rails new myforum
生成 MyForum 的model
rails generate scaffold MyForm title:string descrption:text
把變更移到database
rake db:migrate
編寫seeds.rb文件,批量寫入數(shù)據(jù)
打開db/seeds.rb文件,寫入:
# db/seeds.rb
MyForum.create!(title: 'grocery shopping', descrption: 'pickles, eggs, red onion')
MyForum.create!(title: 'wash the car')
MyForum.create!(title: 'register kids for school', descrption: 'Register Kira for Ruby Junior High and Caleb for Rails High School')
Todo.create!(title: 'check engine light', descrption: 'The check engine light is on in the Tacoma')
Todo.create!(title: 'dog groomers', descrption: 'Take Pinky and Redford to the groomers on Wednesday the 23rd')
在ITerm里執(zhí)行命令
rake db:seed
設置主頁路徑
在 config/routes.rb 文件里, 加入 root 'myforums#index'
最后,在server上預覽,在iTerm中輸入:
rails s