After renaming a field in a table, how do I update the entire Rails project?

Asked

Viewed 696 times

1

I used Scaffold to generate a small project, then I changed the name of a field into a table, (something that’s rare but happens in real life), how do I update the whole project? P.S.: Rake db:migrate has been done without error and the table is already named after the field changed.

1 answer

1


What do you mean by "update the whole project" ? Generate Scaffold again for it?

rails g scaffold <model>

You will have to overwrite the already generated files.

If you have made important changes to the generated files I strongly advise you to do the manual editing (add the field to the views, controllers, etc.).

Don’t forget that if you didn’t use Migration to create this change, just changing the main migration file does not reflect in db:migrate. In this case, you would have to drop the database (db:drop), create it again (db:create), and then migrate (db:migrate). Just BEWARE of these steps because it will erase everything you already have of record, so for migrations always use the command:

rails g migration <acao>

Related links:

  1. Migrations

Browser other questions tagged

You are not signed in. Login or sign up in order to post.