How to rename rails 4 applications?

rails plugin install git://github.com/get/Rename.git will allow us to rename only rails 3 applications

Is there any gem to rename a Rails 4 application.

If not, suggest me the best way to rename.

+61
ruby-on-rails-3 ruby-on-rails-4
Jan 08 '14 at 6:49
source share
7 answers

Since the rails are 4.1.x , if you want to rename the application, you need to change only two files: config/application.rb :

 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 YourApplicationName # <-- rename it here class Application < Rails::Application ... end end 

and config/initializers/session_store.rb (optional):

 # Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_your_application_name_session' # <-- rename the key 



For Rails 4.0.x, you can use the rename gem and run the following command:

 rails g rename:app_to New-Name 

This will update the necessary files for you:

 old/ (master) › rails g rename:app_to new Search and replace module in to... gsub config.ru gsub Gemfile gsub Gemfile.lock gsub Rakefile gsub README.md gsub config/application.rb gsub config/boot.rb gsub config/environment.rb gsub config/environments/development.rb gsub config/environments/production.rb gsub config/environments/test.rb gsub config/initializers/backtrace_silencers.rb gsub config/initializers/filter_parameter_logging.rb gsub config/initializers/inflections.rb gsub config/initializers/load_class_extensions.rb gsub config/initializers/mime_types.rb gsub config/initializers/secret_token.rb gsub config/initializers/session_store.rb gsub config/initializers/update.rb gsub config/initializers/wrap_parameters.rb gsub config/routes.rb gsub config/initializers/session_store.rb Renaming references... Renaming directory...Done! New application path is '/Users/username/code/new' 
+134
May 20 '14 at 7:34
source share

Add

gem 'rename' in the gemfile

then

bundle install

After that

 rails g rename:app_to name_of_app 

And if you use mongoid, you need to rename the database name to config/mongoid.yml

+37
Feb 26 '15 at 8:54
source share

There are two ways:

1. In manual mode (for Rails 4.1.x)

You need to manually find the links to the application name. And you need to change them manually. Here are some common places where it is used:

 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/routes.rb config.ru app/views/layouts/application.html.erb Rakefile 

2. Automatically (for Rails 3 and 4.0.X)

Or you can use rename stone and execute the following command:

 rails g rename:app_to New-Name 
+29
Jan 08 '14 at 8:25
source share

For Rails 5

Require

  • config/application.rb change the module name

Additionally

  • config/initializers/session_store.rb (in Rails.application.config.session_store) change the name of the session
  • app/views/layouts/application.html.erb You can change <title>...</title> if it is not already done
+18
May 13 '16 at 10:12
source share

I just used this rename stone in base application 4:

https://github.com/morshedalam/rename

This is slightly different from the get version.




Ease of use:

Add this to the gemfile:

 gem 'rename' 

And run:

 rails g rename:app_to NewName 



It seemed like a trick,
He also updated my settings for the rubide.idea project :)

+16
Feb 05 '14 at 0:02
source share

In Rails 4.2, just change the application config file

 config/application.rb 

and config / initializers / session_store.rb (optional):

 Rails.application.config.session_store :cookie_store, key: '_your_application_name_session' # <-- rename the key 

then restart the server.

What is it!

+9
Jan 12 '15 at 10:13
source share

Here is a gem specifically for Rails 4 https://github.com/negativetwelve/rails-rename (I have not used it, but it seems beautiful)

The other gems listed here are for Rails 3 only.

0
Nov 10 '15 at 6:02
source share



All Articles