Ruby on Rails 3プロジェクトの名前を変更するための最も効果的で安全かつ簡単な方法は何ですか?
質問する
2742 次
1 に答える
5
これを行うRenameというRails プラグインがあります。2年間更新されていませんが、ほとんど機能しているようです。それは CamelCaseNames を台無しにしますが、一貫した方法です。
必要に応じて、grep
私の例で同様の操作を行い、それらのファイルを手動で変更します (ファイルのリストについては以下を参照してください)。
$ rails new ProjectToRename
$ cd ProjectToRename
$ grep -ri 'project_?to_?rename' .
./config/routes.rb:ProjectToRename::Application.routes.draw do
./config/application.rb:module ProjectToRename
./config/initializers/session_store.rb:ProjectToRename::Application.config.session_store :cookie_store, key: '_ProjectToRename_session'
./config/initializers/session_store.rb:# ProjectToRename::Application.config.session_store :active_record_store
./config/initializers/secret_token.rb:ProjectToRename::Application.config.secret_token = '69761de6e4534f0be37fbebee8e03f1e29d6935e12591444971bccc134503d390cb8b5587d7750a53cc428d3d57a5894437e4b148611623a7f0ff5048aeb4579'
./config/environment.rb:ProjectToRename::Application.initialize!
./config/environments/production.rb:ProjectToRename::Application.configure do
./config/environments/development.rb:ProjectToRename::Application.configure do
./config/environments/test.rb:ProjectToRename::Application.configure do
./app/views/layouts/application.html.erb: <title>ProjectToRename</title>
./Rakefile:ProjectToRename::Application.load_tasks
./config.ru:run ProjectToRename::Application
$ rails plugin install git@github.com:get/Rename.git
$ rails g rename_to SomeNewName
$ grep -ri 'some_?new_?name' .
./config/routes.rb:Somenewname::Application.routes.draw do
./config/application.rb:module Somenewname
./config/initializers/session_store.rb:Somenewname::Application.config.session_store :cookie_store, key: '_ProjectToRename_session'
./config/initializers/session_store.rb:# Somenewname::Application.config.session_store :active_record_store
./config/initializers/secret_token.rb:Somenewname::Application.config.secret_token = '69761de6e4534f0be37fbebee8e03f1e29d6935e12591444971bccc134503d390cb8b5587d7750a53cc428d3d57a5894437e4b148611623a7f0ff5048aeb4579'
./config/environment.rb:Somenewname::Application.initialize!
./config/environments/production.rb:Somenewname::Application.configure do
./config/environments/development.rb:Somenewname::Application.configure do
./config/environments/test.rb:Somenewname::Application.configure do
./Rakefile:Somenewname::Application.load_tasks
./config.ru:run Somenewname::Application
最上位ディレクトリの名前を自分で変更する必要があります。
$ cd ..
$ mv ProjectToRename SomeNewName
于 2013-03-23T22:49:02.590 に答える