rake rails:update

2008/12/15

これから、書籍『基礎 Ruby on Rails』のサンプルアプリケーション asagao を Rails 2.2 に対応させるべく、少しずつ修正していきます。

単に動くようにするだけでなく、できる限り Rails 2.2 で推奨されている流儀で書き直すことを目標にします。

出発点は『基礎 Ruby on Rails』付属 CD-ROM の chapter9 です。

まず、Rails 2.2 のインストールから始めましょう(Windows では sudo を省略してくださいね)。

> sudo gem install rubygems-update
> sudo update_rubygems
> sudo gem install --version=2.2.2 rails

執筆時点では Rails の最新版が 2.2.2 なので、--version オプションは不要ですが、この文章が後で読まれる可能性を考えて付けました。

続いて、asagao の config/environment.rb (8行目)を修正します。

 RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

とりあえず動くかどうかやってみましょう(db:initialize タスクは asagao の独自タスクです)。

> rake db:initialize

次のようなエラーが出ました。

Your config/boot.rb is outdated: Run "rake rails:update".

指示通りやってみます。

rake rails:update

次のような警告が出ますが、boot.rb の書き換えは成功したようです。

Gem::SourceIndex#search support for String patterns is deprecated

では、再挑戦。

&; rake db:initialize

      *******************************************************************
      * config.breakpoint_server has been deprecated and has no effect. *
      *******************************************************************
      
rake aborted!
undefined method `cache_template_extensions=' for ActionView::Base:Class

(See full trace by running task with --trace)

うまく行きませんね。--trace を付けて、もう一度。

&; rake db:initialize --trace

** Invoke db:initialize (first_time)
** Invoke db:create (first_time)
** Invoke environment (first_time)
** Execute environment

      *******************************************************************
      * config.breakpoint_server has been deprecated and has no effect. *
      *******************************************************************
      
rake aborted!
undefined method `cache_template_extensions=' for ActionView::Base:Class
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:530:in `send'
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:530:in `initialize_framework_settings'
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:529:in `each'
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:529:in `initialize_framework_settings'
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:526:in `each'
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:526:in `initialize_framework_settings'
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:154:in `process'
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in `send'
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in `run'
/home/kuroda/hgrepos/books/kiso_rails/cd-rom/chapter9/config/environment.rb:13
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/misc.rake:3
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:238:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:588:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:577:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:238:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:588:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:577:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:238:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

むむ、少し手強そうです。今日は、ここまでとしましょう。