There can be cases where you wished you named that controller a lot better, as it does not make any sense and is very ambiguous in its current form. If you have ever wondered whether there is a way for you to do quick renamings of multiple related files inside a Rails project, then I have some good news for you. There is already a gem called Rails Refactor, that can be used to do these renamings.
It is really simple and easy to use. As with any other Rails gem, you can install it quite easily by putting the following in your Gemfile:
gem install rails_refactor
Then you obviously need to restart your server and expect this gem to be available inside your project.
To rename a controller, you can simply use the following command:
rails_refactor rename OldController NewController
* rename controller file & class name in file
* rename controller spec file & class name in file
* rename view directory
* rename helper file & module name in file
* update routes
You can also rename only a controller model using the following:
rails_refactor rename DummyController.old_action new_action
* renames controller action in controller class file
* renames view files for all formats
You can rename a model using the following:
rails_refactor rename OldModel NewModel
* rename model file & class name in file
* rename spec file & class name in file
* rename migration & class name & table names in file
You can view the source code of this project on its Github page and can also contribute and make it even better.