Rails 3.0 リリースノート和訳 - 前編 - おもしろWEBサービス開発日記に書かれている、アップグレードの一部を自動化してくれるプラグインrails_upgradeについてのメモです。
インストール方法
script/plugin install git://github.com/rails/rails_upgrade.git
rake rails:upgrade:check
アプリのソースをみて、Rails 3 にアップグレードするために必要なことをレポートしてくれる。コメント内のソースにも反応するので注意。
実行例
Old router API
The router API has totally changed.
More information: http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/
The culprits:
- config/routes.rb
Deprecated test_help path
You now must require 'rails/test_help' not just 'test_help'.
More information: http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices
The culprits:
- /home/willnet/hoge/test/test_helper.rb
New file needed: config/application.rb
You need to add a config/application.rb.
More information: http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade
The culprits:
- config/application.rb
Deprecated constant(s)
Constants like RAILS_ENV, RAILS_ROOT, and RAILS_DEFAULT_LOGGER are now deprecated.More information: http://litanyagainstfear.com/blog/2010/02/03/the-rails-module/
The culprits:
- /home/willnet/hoge/lib/tasks/rspec.rake
Old gem bundling (config.gems)
The old way of bundling is gone now. You need a Gemfile for bundler.
More information: http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade
The culprits:
- /home/willnet/hoge/config/environment.rb
rake rails:upgrade:backup
アップグレードで変更されてしまうかもしれないファイルをバックアップしてくれる。これはかなり便利!
実行例
* backing up .gitignore to .gitignore.rails2 * backing up app/controllers/application_controller.rb to app/controllers/application_controller.rb.rails2 * backing up app/helpers/application_helper.rb to app/helpers/application_helper.rb.rails2 * backing up config/routes.rb to config/routes.rb.rails2 * backing up config/environment.rb to config/environment.rb.rails2 * backing up config/database.yml to config/database.yml.rails2 * backing up doc/README_FOR_APP to doc/README_FOR_APP.rails2 * backing up test/test_helper.rb to test/test_helper.rb.rails2 This is a list of the files analyzed and backed up (if they existed); you will probably not want the generator to replace them since you probably modified them (but now they're safe if you accidentally do!). - .gitignore - app/controllers/application_controller.rb - app/helpers/application_helper.rb - config/routes.rb - config/environment.rb - config/environments/* - config/database.yml - doc/README_FOR_APP - test/test_helper.rb
rake rails:upgrade:gems
environment.rb中のconfig.gemをみてGemfileを生成してくれる。
rake rails:upgrade:routes
config/routes.rbをみてRails3用のルーティングコードを生成してくれる
rake rails:upgrade:configuration
config/environment.rbをみてconfig/application.rb用のコードを生成してくれる。
感想
とりあえず一通り使ってみましたがcheckとbackupは使えるコマンドでした。使ってみたのがかなり小さいアプリだったので他のコマンドが有効かどうかはいまいちわかりませんでした。仮にcheckとbackupだけでも、Rails2系から3にアップグレードを予定している方には有効だと思います