Renaming a Rails 4 Application

Renaming rails applications before Rails 4.1 was easiest via the rename gem, but I’ve had good success renaming Rails 4.1.x + applications, following the suggestions in the answer to this question on StackOverflow. Essentially, since Rails 4.1, it is only really necessary from the perspective of the framework to change the application name in two files.

config/application.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module CurrentApplicationName # <-- CHANGE APPLICATION NAME HERE
  class Application < Rails::Application
    ...
    # removed for brevity
    ...
    config.active_record.raise_in_transactional_callbacks = true
  end
end
config/initializers/session_store.rb
1
2
3
4
5
# Be sure to restart your server when you modify this file.

Rails.application.config.session_store :cookie_store, key: '_current_application_name_session'

# change the _current_application_name_ in the key above to your _new_application_name_

As long as your application was created as a Rails 4.1.x + application or properly upgraded, this is all you should need to do, although if your application name is also reflected in your views or tests, you’ll also want to make some changes in those as well. In that case, if you use Sublime Text editor, you can do a find and replace of the app and test folders in your project.

Created 3/11/2015 12:34PM (MDT) | Last Updated 3/16/2015 5:34PM (MDT)

Comments

Log in to add comments.