简体   繁体   English

如何彻底更改由脚手架生成的模型的名称?

[英]How do I change the name of a model generated by scaffold cleanly?

I have a model called ModelA that I want to rename to ModelB . 我有一个名为ModelA的模型,我想将其重命名为ModelB

I generated ModelA by doing rails g scaffold ModelA . 我产生ModelArails g scaffold ModelA That generated the model, controller, views, specs, routes, etc. 生成了模型,控制器,视图,规格,路线等。

How do I cleanly change the name of ModelA given that I have setup associations, join tables, etc. 考虑到我具有设置关联,联接表等,如何干净地更改ModelA的名称。

Also, how do I do it such that my local environment is in sync with Heroku when I push. 另外,当我按下按钮时,我该如何做到使本地环境与Heroku同步。

I feel like it is very easy to mess this up. 我觉得这很容易弄乱。

If you have released your code to an environment where you can't drop tables, you will just have to hand write migrations. 如果您已将代码发布到无法删除表的环境中,则只需要手写迁移即可。 No out-of-the-box rails way for the same. 没有开箱即用的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM