I’ve had to change Rails 3 project names a few times now. It’s too bad there’s no rake command for it. Here’s the next best thing: a step-by-step guide.
For the sake of this example, let’s say I’m changing my name name from “Teach” to “Learn”.
Update your app’s module name
In /config/application.rb, change the name of the module:
1 2 3 4 5 | |
Update references to your app’s module name
Your app’s module name should appear in /config.ru:
1 2 3 4 | |
And in /Rakefile:
1 2 3 4 5 6 7 | |
Your app’s module name should also appear in a bunch of files under the /config directory. It should appear in /config/environments.rb.
1 2 | |
It should also appear in all the environment-specific configurations in /config/environments/*.rb (which should be development.rb, production.rb, test.rb, and any other environments you have configured). Change them all:
1 2 3 4 | |
And in your initializers (under /config/initializers/). At the very least, /config/initializers/secret_token.rb and /config/initializers/session_store.rb should have it:
1 2 3 4 5 6 | |
1 2 3 4 5 6 7 8 9 | |
And in your /config/routes.rb file:
1 2 3 | |
Finally, for consistency’s sake, if the names of your databases include your app name, you should update those in /config/database.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
Search your app and lib folders
grep through your /app and /lib folders to find any mentions of your project name and change them. This might be a little tedious if you have a name that conflicts with a bunch of Ruby/Rails stuff (like “def” or something stupid like that), but you only have to do it once.
Done!
That’s it! Now you have a renamed Rails 3 app.
Note: I did this on Rails 3.2.1. It’s possible some things will be different on other versions.