在 Rails 中撤消脚手架 [英] Undo scaffolding in Rails

查看:58
本文介绍了在 Rails 中撤消脚手架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以撤销"Rails 中脚手架命令的效果?

Is there any way to 'undo' the effects of a scaffold command in Rails?

推荐答案

首先,如果您已经运行了 scaffold 命令生成的迁移,则必须执行先回滚.

First, if you have already run the migrations generated by the scaffold command, you have to perform a rollback first.

rake db:rollback

您可以使用以下方法创建脚手架:

You can create scaffolding using:

rails generate scaffold MyFoo 

(或类似的),并且您可以使用

(or similar), and you can destroy/undo it using

rails destroy scaffold MyFoo

这将删除 generate 创建的所有文件,但不会删除您可能手动进行的任何其他更改.

That will delete all the files created by generate, but not any additional changes you may have made manually.

这篇关于在 Rails 中撤消脚手架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆