自分の興味の赴くままにIT技術系のネタを取りとめもなくメモっています。
Ruby言語やLinuxのネタが多いです。
Ruby言語やLinuxのネタが多いです。
March 09, 2010 [おもひで]
■ [Rails] 3.0 betaを試してみる(3) rake rails:upgrade:check
間が空いちゃったけど、前回の続き。
まずは、rake rails:upgrade:checkでチェックしてみよう。
% rvm 1.8.7%rails235 (Rails-2.3.5環境で実施) % rake rails:upgrade:check (in /home/mutoh/dev/git/gettext_rails/sample_rails3) 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/mutoh/dev/git/gettext_rails/sample_rails3/config/environment.rb Soon-to-be-deprecated ActiveRecord calls Methods such as find(:all), find(:first), finds with conditions, and the :joins option will soon be deprecated. More information: http://m.onkey.org/2010/1/22/active-record-query-interface The culprits: - /home/mutoh/dev/git/gettext_rails/sample_rails3/app/controllers/articles_controller.rb - /home/mutoh/dev/git/gettext_rails/sample_rails3/app/helpers/articles_helper.rb 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/mutoh/dev/git/gettext_rails/sample_rails3/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/mutoh/dev/git/gettext_rails/sample_rails3/app/controllers/application_controller.rb - /home/mutoh/dev/git/gettext_rails/sample_rails3/app/models/article.rb
むぅ。いっぱいあるのぅ。
%rake rails:upgrade:backup (in /home/mutoh/dev/git/gettext_rails/sample_rails3) * 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
.rails2という拡張子をつけてバックアップが取られるのね。
■ [Rails] 3.0 betaを試してみる(5) rake rails:upgrade:gems
check時に「Old gem bundling (config.gems)」と出力されたのをバージョンアップしてくれる。
3.0では、config.gemを使用せずに、Bundlerというライブラリを使用してGemfileに使用するgemを追加する形に変更されたのでそれの対応。でも、Gemfileって、config/配下じゃなくて、RAILS_ROOT直下に置くのね…。
% rake rails:upgrade:gems > Gemfile
% cat Gemfile
# Edit this Gemfile to bundle your application's dependencies.
# This preamble is the current preamble for Rails 3 apps; edit as needed.
path "/path/to/rails", :glob => "{*/,}*.gemspec"
git "git://github.com/rails/rack.git"
gem "rails", "3.0.pre"
gem 'locale_rails'
gem 'gettext_activerecord'
gem 'gettext_rails'
config/environment.rbにあるconfig.gemの行は削除しておく。
% rake rails:upgrade:routes > new_routes.rb
% mv new_routes.rb config/routes.rb
% cat config/routes.rb
(in /home/mutoh/dev/git/gettext_rails/sample_rails3) #この行は不要なので削除する。
SampleRails3::Application.routes.draw do
resources :articles
match '/:controller(/:action(/:id))'
end
だいぶ変わったなー。SampleRails3というのが本アプリのクラス名になる、ということかな。
% rake rails:upgrade:configuration > config/application.rb
% cat config/application.rb
(in /home/mutoh/dev/git/gettext_rails/sample_rails3) #不要なので削除する。
# Put this in config/application.rb
require File.expand_path('../boot', __FILE__)
module SampleRails3
class Application < Rails::Application
:
:
end
end
中身は旧config/environment.rbをコピーした感じ。
config/environment.rbは以下のように書き換える。こちらは自動じゃないのか。
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
#YourApp::Application.initialize!
SampleRails3::Application.initialize! #自分のアプリ用に書き換える。
% rvm 1.8.7%rails3beta % ruby script/server /home/mutoh/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems.rb:230:in `activate': can't activate rails (= 2.3.2, runtime) for [], already activated rails-3.0.0.beta for [] (Gem::LoadError) from /home/mutoh/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in `require' from ./script/../config/boot.rb:54:in `load_initializer' from ./script/../config/boot.rb:38:in `run' from ./script/../config/boot.rb:11:in `boot!' from ./script/../config/boot.rb:109 from script/server:2:in `require' from script/server:2
がーん。ちと出直します…。
[ツッコミを入れる]
