Reputation: 2092
I am having a fairly simple problem, I like rename a model called 'Person' to 'User'.
I know that I can simply run a migration to rename the table and rename the model file itself. But in a typical app there are many more references to the model such as in
And the more complex ones such as names of associations such as 'person_id'.
Looking on the web I only found solutions that scratch the surface such as Refactoring in RubyMine. I can image a Question:Yes/No interactive shell based solution that guides through the process. Without it, epecially in larger/mature projects, this is a very tedious and error prone process.
Any solutions to that?
Upvotes: 1
Views: 449
Reputation: 15912
Spin up your favorite text editor and use Find and Replace.
Perhaps at first glance this technique may seam cumbersome; but there is value in the approach.
In your example of Person (User) and person_id (user_id) 3. You only make the corrections needed to run your next tests. example: Change Person to User, then run your test suite to see that nothing is broken, if so fix it. Then move to the next word(s) you need to change, in this case it was person_id to user_id. When you changed Person, it shouldn't matter that person_id was not changed yet (unless you are using the class name to make a variable of some kind, which you will find during #2 anyway). Now you go through the change process to find person_id, etc... repeat as necessary.
I personally like to see each change being made, as I do not like introducing unknown bugs that I would waste even more time on TS'ing.
This is not exactly what you were looking for, but perhaps it helps somewhat.
Upvotes: 1