ruby-on-rails-3 – 如何重命名rails 4应用程序?

rails plugin install git://github.com/get/Rename.git将允许我们重命名rails 3应用程序

是否有任何gem可以重命名Rails 4应用程序。

如果没有,建议我更好的方式重命名。

最佳答案
由于rails 4.1.x,如果你想重命名你的应用程序,你需要修改的唯一两个文件是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

和config / initializers / session_store.rb(可选):

# 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

对于Rails 4.0.x,您可以使用rename gem并执行以下命令:

rails g rename:app_to New-Name

这将为您更新必要的文件:

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'

转载注明原文:ruby-on-rails-3 – 如何重命名rails 4应用程序? - 代码日志