重命名Ruby on Rails 3 项目的最强有效,安全和最简单方法是什么?
答案 0 :(得分: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