简体   繁体   English

在 Rails (7.0.4) 中,有什么方法可以更改整个应用程序的属性名称吗?

[英]In Rails (7.0.4) , Is there any way to change a attribute name from all over our application?

I wanna change "Author" to "Author_name" in my rails application.我想在我的 Rails 应用程序中将“Author”更改为“Author_name”。

So I have used "rename_column" method in the migration, then after running migration my column name is changed but after that I have to manually change it everywhere from my code ( Controller and view )所以我在迁移中使用了“rename_column”方法,然后在运行迁移后我的列名被更改但之后我必须在我的代码中到处手动更改它(Controller 和视图)

It's not a question to Rails, but to your code editor.这不是 Rails 的问题,而是您的代码编辑器的问题。 You just need to perform search and replace.您只需要执行搜索和替换。

So I have got my solution, This is a editor problem not a Rails one.所以我得到了我的解决方案,这是一个编辑器问题,而不是 Rails 问题。 I'm using Vs-code, we can do Ctrl + Shift + H .我正在使用 Vs-code,我们可以执行Ctrl + Shift + H It will open a search and replace window.它将打开搜索并替换 window。

在此处输入图像描述

You can change whatever you wanna change,你可以改变任何你想改变的,

在此处输入图像描述

Thank you.谢谢你。

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

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