巧用脚手架scaffold

//删除所有由脚手架生成的文件

例如删除由ruby script/generate scaffold test title:string生成的所有文件,

方法:ruby script/destroy scaffold tests

 

 

//通过migration给表增加字段,索引(index)..........

script/generate migration add_column_to_model_name column_name:column_type

rake db:migrate

 

例如: script/generate migration add_column_to_product  price:decimal

或者script/generate migration  add_price_to_product  price:decimal

 

 

 

//删除某些字段,应该是:

script/generate migration remove_column_from_model  column_name:column_type

rake db:migrate

你可能感兴趣的:(Ruby,Rails)