Categories
Ruby on Rails Software Development

How to Rename a Rails App

There are a number of reasons you’d want to rename your Rails 3 app. To do so quickly, search and replace the following files of a standard Rails 3 application:

  • config/application.rb
  • config/environment.rb
  • config/environments/development.rb
  • config/environments/test.rb
  • config/environments/production.rb
  • config/routes.rb
  • config.ru
  • config/initializers/secret_token.rb
  • config/initializers/secret_store.rb

Obviously, if you referenced your app in any other files, you’ll want to change them there, too.

From StackOverflow:

In Rails 3, it’s a little different. Rails 3 projects are name-spaced to a module defined inconfig/application.rb. This application module is used to house your app, and you’ll see it referenced by your config.ruconfig/routes.rbconfig/environment.rb and all the environments defined in config/environments/.

If you were to open a terminal session and run the command rails new myapp, yourconfig/application.rb file would define the module Myapp, inside which will be defined an Application class, which extends Rails::Application. All the other files will referenceMyapp::Application.

In both Rails 2 and 3, you will find a string key for your session defined inconfig/initializers/session_store.rb, which takes the default value of ‘_<myapp>_session’. It’s not really tied to the “name” of your application, though you should try to keep it in sync to prevent any accidental session key name conflicts with other apps.