Reputation: 1026
rails plugin install git://github.com/get/Rename.git
will allow us to rename only rails 3 app
Is there any gem available to rename Rails 4 app.
If not, suggest me the better way to rename.
Upvotes: 63
Views: 30776
Reputation: 1357
For Rails 6.1 Here is what I did:
rename module config/application.rb
run bundle install
and run rails db:migrate
.
after that running rails c
then Rails.application.class.module_parent.name
Upvotes: 0
Reputation: 2061
How to Rename a Rails 6.1.3 Application
the "rename" gem doesn’t appear to be tested against Rails 6 at this time according to their documentation so I opted for the manual route.
npm install
so that the name attribute you previously updated in package.json is registered.rails db:migrate
rails s
Upvotes: 0
Reputation: 52897
For rails 5.2
Add gem 'rename'
to the gemfile
bundle install
rails g rename:into your_new_app_name
Upvotes: 1
Reputation: 3134
In Rails 5.x, doing it manually
using ag (https://github.com/ggreer/the_silver_searcher), there are files that use the default folder name (if generated via rails new .)
three basic files, relative to root of project, need to be updated:
There are sure to be more locations as mentioned previously such as database etc. Hope this helps.
Upvotes: 0
Reputation: 777
Add
gem 'rename'
to Gemfile
then
bundle install
After that
rails g rename:app_to name_of_app
And if you are using mongoid then you need to rename the database name in config/mongoid.yml
Upvotes: 36
Reputation: 3895
There are two ways:
1 . Manually (For Rails 4.1.x)
You need to manually find the references to the application name. And you need to change them manually. Here is 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 . Automatic (For Rails 3 and 4.0.X)
Or you can use the rename gem and execute the following command:
rails g rename:app_to New-Name
Upvotes: 29
Reputation: 9480
For Rails 5
Require
config/application.rb
change the module nameOptional
config/initializers/session_store.rb
(in Rails.application.config.session_store) change the session nameapp/views/layouts/application.html.erb
You can change the <title>...</title>
, if it is not already doneUpvotes: 23
Reputation: 493
Here is a gem specifically for Rails 4 https://github.com/negativetwelve/rails-rename (I haven't used it but it seems fine)
The other gems listed here only target Rails 3
Upvotes: 0
Reputation: 32070
In Rails 4.2 just change in 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 your server.
That's it!
Upvotes: 9
Reputation: 4173
Since rails 4.1.x, if you want to rename your application, the only two files you need to modify are 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 execute 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'
Upvotes: 136
Reputation: 2710
I just used this rename
gem in a basic rails 4 app:
https://github.com/morshedalam/rename
This is quite a bit different to get
's version.
Easy enough to use:
Add this to Gemfile:
gem 'rename'
And run:
rails g rename:app_to NewName
Seemed to the trick,
It also updated my rubymine .idea project settings :)
Upvotes: 16