如何在不重新创建脚手架的情况下更改脚手架的名称? [英] How to change name of Scaffold without recreating it?

查看:59
本文介绍了如何在不重新创建脚手架的情况下更改脚手架的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个脚手架示例",并对其控制器和视图进行了许多更改.

I created a scaffold "example" and have made many changes to its controller and views.

现在我想将它重命名为sample",有什么办法可以做到不破坏任何东西?手动编辑控制器、模型、视图和迁移文件会很困难,所以我希望可能有一些东西可以缓解这种情况.

Now I want to rename it to "sample", is there any way to do it without breaking anything ? it will be difficult to manually edit controller, model, views and migration file so I was hoping there may be something to ease up this.

推荐答案

目前无法实现.

您需要手动编辑现有控制器.您可以使用高级 IDE(例如 RubyMine)来帮助您完成工作.

You will need to edit the existing controller manually. You can use and advanced IDE, such as RubyMine, to help you with the job.

另外,我不建议你改变现有的脚手架.您可以创建一个新的,确保它正常工作,然后删除旧的.

Also, I don't suggest you to change the existing scaffold. You can create a new one, make sure it's working properly, then remove the old one.

请注意不要重命名迁移,否则您的应用可能会崩溃.迁移一旦应用就不应更改,要更改架构,您应该创建新的迁移.

Be careful to not rename migrations or your app it's likely to break. Migrations should not be changed once applied, to change the schema you should create a new migration.

这篇关于如何在不重新创建脚手架的情况下更改脚手架的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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