你采取了哪些措施来消除Rails开发中的错误?

时间:2021-10-16 21:11:03

A single Rails command can make lots of changes in an app - creating files and migrations, adding routes, etc. Undoing the damage of a mistake could be tricky for a beginner.

单个Rails命令可以在应用程序中进行大量更改 - 创建文件和迁移,添加路由等。对于初学者来说,撤消错误的损坏可能会非常棘手。

For example, say you generate some scaffolding, run the migration, and then realize your scaffolding command should have been singular (ruby script/generate scaffold cake type:string) instead of plural (ruby script/generate scaffold cakes type:string).

例如,假设您生成一些脚手架,运行迁移,然后实现您的脚手架命令应该是单数(ruby脚本/生成脚手架蛋糕类型:字符串)而不是复数(ruby脚本/生成脚手架蛋糕类型:字符串)。

If you destroy the scaffolding before rolling back the database migration, you've created another problem.

如果在回滚数据库迁移之前销毁脚手架,则会产生另一个问题。

So: what steps do you take to undo mistakes in Rails development?

那么:你采取了哪些措施来消除Rails开发中的错误?

3 个解决方案

#1


Always, always put your Rails application under version control. It doesn't really matter if you want to use Git, Mercurial or SVN... regardless your choice, don't start a Rails project without a Version Control System.

始终,始终将您的Rails应用程序置于版本控制之下。如果你想使用Git,Mercurial或SVN并不重要......无论你选择什么,都不要在没有版本控制系统的情况下启动Rails项目。

A SCM tool is your global UNDO button.

SCM工具是您的全局UNDO按钮。

#2


You can use the destroy command.

您可以使用destroy命令。

After you type

输入后

ruby generate scaffold cake type:string

ruby生成脚手架蛋糕类型:字符串

You can delete it by typing

您可以通过键入来删除它

ruby destroy scaffold cake type:string

ruby破坏脚手架蛋糕类型:字符串

#3


To undo a rails command use the destroy command. e.g.

要撤消rails命令,请使用destroy命令。例如

rails generate controller users

rails生成控制器用户

rails destroy controller users

rails销毁控制器用户

#1


Always, always put your Rails application under version control. It doesn't really matter if you want to use Git, Mercurial or SVN... regardless your choice, don't start a Rails project without a Version Control System.

始终,始终将您的Rails应用程序置于版本控制之下。如果你想使用Git,Mercurial或SVN并不重要......无论你选择什么,都不要在没有版本控制系统的情况下启动Rails项目。

A SCM tool is your global UNDO button.

SCM工具是您的全局UNDO按钮。

#2


You can use the destroy command.

您可以使用destroy命令。

After you type

输入后

ruby generate scaffold cake type:string

ruby生成脚手架蛋糕类型:字符串

You can delete it by typing

您可以通过键入来删除它

ruby destroy scaffold cake type:string

ruby破坏脚手架蛋糕类型:字符串

#3


To undo a rails command use the destroy command. e.g.

要撤消rails命令,请使用destroy命令。例如

rails generate controller users

rails生成控制器用户

rails destroy controller users

rails销毁控制器用户