Renaming a Rails app is not a difficult task and can be handled manually. Let's see how.

· Rails  · 1 min read

How to rename a Rails app

Renaming a Rails app is not a difficult task and can be handled manually. Let's see how.

How the Rails your app name was defined

First, the name of your Rails app comes from the “rails new myapp” command. In this example, “myapp” is the name of your Rails app.

  • It creates a folder named “myapp” and put all the default files and directories inside,
  • The main module of the application (under config/application.rb) is named “Myapp” (beware of the first capitalized letter)
  • Some files contains the word “myapp” - like package.json, but I won’t list all files here, it depends on what version of Rails and what options you passed to the “rails new” command. Just use the “search and replace” command of your editor.

You will rename occurrences at least 3 times

  • rename the top folder,
  • rename the module under config/application.rb
  • do a find all/replace all for all the remaining occurrences.

Warning, if the original name was too generic, like “rails” or “app”, there could be occurrences that do not concern your app’s name.

Pay extra attention to the case. Ruby is case-sensitive, so don’t go too fast when replacing occurrences.

Conclusion

Renaming a Rails app is not an anxious task. Just take time to change occurrences with care, it will work seamlessly.

And, of course, after that, run your test suite ;)

Share:
Back to Blog

Related Posts

View All Posts »
Rails 8 Hotwire, a tutorial

Rails 8 Hotwire, a tutorial

Rails 8 comes with Hotwire by default to handle frontend complexity. Here is a simple tutorial from scratch.

Ruby-on-Rails ERB vs HAML

Ruby-on-Rails ERB vs HAML

This is an opinionated article about ERB and HAML with Rails. Let's compare each other and pick a winner.