Lots out there about changing model names only or mapping new models to existing tables, but nothing about renaming both at the same time. For now, I'm starting with the DB table and working my way out with Find/Replace in my code, but I'm surprised there isn't something better or at least someone who's tried it and written about it.
+1
A:
The full list of things to rename are:
- table name
- foreign key column names in associations (model_id columns)
- model file name in app/models/
- class name in app/models/model.rb
- associations in other models (has_one/has_many)
- controller file name in app/controllers/
- class name in app/controllers/models_controller.rb
- folder name in app/views/
- resource route in config/routes.rb
- fixture file name in test/fixtures/
- references to the model in associated fixtures in test/fixtures/
- unit test file name in test/unit/
- class name in test/unit/model_test.rb
- controller test file name in test/functional/
- class name in test/functional/models_controller_test.rb
- find/replace the class name anywhere in your code
You should write a migration for the database changes. The rest can be done easily, or you can use your IDE (RadRails/RubyMine) to help. I guess there's no built in function because there's no way to know where in your code you've used the model.
Andrew Vit
2010-07-14 01:03:10
If I've missed anything, please add it. :)
Andrew Vit
2010-07-14 01:03:26
Excellent, I will add anything I find! Thank you Andrew!
kbighorse
2010-07-30 22:19:22