How to change a Ruby on Rails application name?

I have a Ruby on Rails application that was created using:

rails new old_name -d mysql

Now I want to change the application name to be new_name.

Just changing the application folder name will not be enough, because the database name, for example, also has to be changed (from old_name_development to new_name_development). I wonder if there are other places in the automatically generated files that needs changing.

Is there any built in command for changing the application name ?


Solution 1:

In Rails 3, there are references to the application name in the following files:

  • config/application.rb
  • config/environment.rb
  • config/environments/development.rb
  • config/environments/production.rb
  • config/environments/test.rb
  • config/initializers/secret_token.rb
  • config/initializers/session_store.rb
  • config/mongoid.yml (if using Mongoid)
  • config/routes.rb
  • config.ru
  • Rakefile
  • app/views/layouts/application.html.erb, in title tag

Solution 2:

There's a Rails plugin to do it for you. Super convenient.

https://github.com/get/rename

Solution 3:

in Rails 3, the application class is defined in config/application.rb, and referred to in your environment files (config/environment.rb, config/environments/*.rb) and config/routes.rb. I think that's it, but you should find out pretty quickly from rails server if you missed one. :)

  • config/application.rb
  • config/enviroment.rb
  • config/environments/*.rb
  • config/routes.rb

That said, unless you've got a very specific reason for wanting it changed, I wouldn't bother. Doesn't really affect the application in any other way.

Solution 4:

Rails 3 application can rename using https://github.com/morshedalam/rename