(摘录来自: persie. “Ruby on Rails 教程”)
short key
1 2 3
| g generate d destory s server
|
脚手架以及一些常用的变量类型
1
| rails g scaffold user name:string age:int email:string description:text cash:float
|
删除脚手架生成的代码
生成Controller与action
1
| rails g controller TodoList list delete index
|
删除Controller
1
| rails d controller TodoList list delete index
|
生成Model
1
| rails g model User name:string email:string
|
删除Model
1
| rails d model User name:string email:string
|
添加字段到表
1
| “rails generate migration add_password_digest_to_users password_digest:string”
|
根据Model生成数据库表