创建Rails脚手架
1、帮助中心表格
序号 | 字段 | 类型 | 属性说明 | 备注 |
1 | belong_to | String | 所属栏目 |
|
2 | question | text | 问题 |
|
3 | answer | text | 答案 |
|
4 | editor | String | 编辑人 |
|
2、创建help_tab脚手架程序
(1)进入D:根目录
(2)创建文件夹helps
(3)创建项目:rails new help
(4)进入项目目录:cd help
(5)创建脚手架:rails generate scaffold help_tab belong_to:string question:text answer:text
(6)数据迁移:rake db:migrate
(7)查看路径:D:\helps\help>rake routes
3、运行
(8)启动服务器:rails s
(9)浏览器输入网址:http://localhost:3000/help_tabs
4、抓图
4.1列表页面
4.2 添加页面
4.3 show页面
4.4添加编辑人
D:\helps\help>rails generate migration add_editor editor:string