The other answers and comments covered table renaming, file renaming, and grepping through your code.
I'd like to add a few more caveats:
Let's use a real-world example I faced today: renaming a model from 'Merchant' to 'Business.'
- Don't forget to change the names of dependent tables and models in
the same migration. I changed my Merchant and MerchantStat models to Business and BusinessStat at the same time. Otherwise I'd have had to do way too much picking and choosing when performing search-and-replace.
- For any other models that depend on your model via foreign keys, the other tables' foreign-key column names will be derived from your original model name. So you'll also want to do some rename_column calls on these dependent models. For instance, I had to rename the 'merchant_id' column to 'business_id' in various join tables (for has_and_belongs_to_many relationship) and other dependent tables (for normal has_one and has_many relationships). Otherwise I would have ended up with columns like 'business_stat.merchant_id' pointing to 'business.id'. Here's a good answer about doing column renames.
- When grepping, remember to search for singular, plural, capitalized,
lowercase, and even UPPERCASE (which may occur in comments) versions
of your strings.
- It's best to search for plural versions first, then singular. That
way if you have an irregular plural - such as in my merchants ::
businesses example - you can get all the irregular plurals correct.
Otherwise you may end up with, for example, 'businesss' (3 s's) as an
intermediate state, resulting in yet more search-and-replace.
- Don't blindly replace every occurrence. If your model names collide
with common programming terms, with values in other models, or with
textual content in your views, you may end up being too over-eager.
In my example, I wanted to change my model name to 'Business' but
still refer to them as 'merchants' in the content in my UI. I also had a 'merchant' role for my users in CanCan - it was the confusion between the merchant role and the Merchant model that caused me to rename the model in the first place.