How to rename a Rails 3 Application

Tue Jan 19 14:01:00 -0800 2010

Renaming a Rails 3 application is something you have to think about now. No, really… :)

When you create a new Rails 3.0 app with “rails app_name” Rails will create the application for you like before, but with a major difference.

It will Classify your “app_name” and use this as the Ruby name space for your application.

So if you do:

rails new app_name

Then your Rails application will have sprinklings of AppName throughout the tree.

If you later decide that your application should be called something more specific than “AppName” you need to replace out AppName from the following files:

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

Of course, if you are using TextMate, a simple Project wide search and replace for AppName with your new name, should do the trick. But it is something to be aware of.

blogLater

Mikel

Edited 21 Sept 2010: to update per reader comments below.

  1. Kieran P Says:

    There was a commit recently that eliminated some of these locations you need to change. The last 3 on your list (Rakefile, and script/*) now point to Rails::Application, Rails::Console, or Rails::DBConsole, and not AppName anymore.

  2. Androme Says:

    This is a nice and precise info on the subject. legal studies degree online fire science school public administration school Law Degree Law and legal studies school Law Degree

  3. seadh Says:

    The command is “rails new app_name” to create an app.

  4. Daze Says:

    The command is “rails new app_name” to create an app.

    good post though -

  5. eric Says:

    I realize this post is out of date, so here’s an update

    remove:
    script/console
    script/dbconsole
    from the list

    add:
    initializers/secret_token.rb
    initializers/session_store.rb
    to the list

  6. Mikel Lindsaar Says:

    @Kieran, @Daze and @eric thanks! I have updated. the post to match.

  7. Veeti Paananen Says:

    You should add the Rakefile to your list again. Thanks!

  8. G. Koren Says:

    You can use the Rename plugin

    https://github.com/get/Rename

  9. gift baskets Says:

    This is exactly the good that I have been looking, Thanks for this. Thanks for the codes.

  10. gift baskets Says:

    This is exactly the good that I have been looking, Thanks for this. Thanks for the codes.

  11. asdg4dfg Says:

    There was a commit recently that eliminated some of these locations you need to change. The last 3 on your list (Rakefile, and script/*) now point to Rails::Application, Rails::Console, or Rails::DBConsole, and not AppName anymore sg ksygnnvhg hg tthjobhmt te zipoxihuu

  12. Demir Leather Says:

    I had joined a multicultural choir Suara Mas, where we sang songs in all the languages of Malaysia.

  13. Funeral Says:

    I had joined a multicultural choir Suara Mas, where we sang songs in all the languages of Malaysia.

  14. astrologie Says:

    However I’d like to think that it’s more to me than just sales and I have for example this winter acquired a taste for cross country skiing.

  15. Lebanon Web Design Says:

    The Coffee Shop, operated by the Scudamores on Gloucester.

  16. cat scores Says:

    I have been looking, Thanks for this. Thanks for the codes.

  17. http://www.accidentsdirect.com Says:

    Of course, if you are using TextMate, a simple Project wide search and replace for AppName with your new name, should do the trick.

  18. jibran Says:

    The best person to give you medical advice about liver disease is your doctor. Best thing we can do is recommend perhaps a good doctor if you need a second or third opinion. casino

Leave a Reply