Rails3.0.5→3.1.1

rails3.0.6から3.1.1にアップデートしたときのメモ

■ 新規:テストプロジェクト作って試してみる

$ rails new test_pjt -d mysql
$ cd test_pjt/
$ vi Gemfile #バージョン指定全部はずす
$ sudo bundle install
$ rails g scaffold bookmark title:string comment:text
$ rake db:create
$ rake db:migrate
$ rails s

ここまで順調。
ちなみに入ったGemは以下

Installing rake (0.9.2)
Using multi_json (1.0.3)
Installing activesupport (3.1.1)
Installing builder (3.0.0)
Installing i18n (0.6.0)
Installing activemodel (3.1.1)
Installing erubis (2.7.0)
Installing rack (1.3.4)
Installing rack-cache (1.1)
Installing rack-mount (0.8.3)
Installing rack-test (0.6.1)
Installing hike (1.2.1)
Installing tilt (1.3.3)
Installing sprockets (2.0.3)
Installing actionpack (3.1.1)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Installing mail (2.3.0)
Installing actionmailer (3.1.1)
Installing arel (2.2.1)
Installing tzinfo (0.3.30)
Installing activerecord (3.1.1)
Installing activeresource (3.1.1)
Using bundler (1.0.14)
Installing json (1.6.1) with native extensions
Installing mysql2 (0.3.7) with native extensions
Installing rack-ssl (1.3.2)
Installing rdoc (3.11)
Using thor (0.14.6)
Installing railties (3.1.1)
Installing rails (3.1.1)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

で、ブラウザで動作確認してみたら2点エラー

■ERROR NoMethodError: undefined method `debug_rjs=' for
ActionView::Base:Classの対策
 Rails3.1でEpigraphを(なんとか)動かす - Ruby1.9とRails3で何か作ってみる http://bit.ly/ogROsB 「config/environments/xxx」ファイルに記述されている、
 config.action_view.debug_rjs = true
 この設定がもはやなくなったようで、この行を消したら無事動くようになった。

■[Ruby] やっと Rails 3.1.0 にバージョンアップしたときのエラーを解消できた: 遠回りするかな http://bit.ly/nQNMUx
<%= javascript_include_tag :defaults %>修正→<%= javascript_include_tag "application" %>
上記2点の対応でとりあえずscaffoldアプリは動いた。


■既存:PJTのアップデート
■参考文献はないものか?
ちょうど同じ境遇の人いた
Rails 3.0.5から3.1.1へアップグレード - 発声練習


■もしかして:簡単?
Gemfile書き換えて、bundle updateするだけ?

$ gem "rails", "3.1.0" 
$ bundle update


■やってみよう

$ bundle update
Fetching source index for http://rubygems.org/

Enter your password to install the bundled RubyGems to your system:
Using rake (0.9.2)
Using multi_json (1.0.3)
Using activesupport (3.1.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.1)
Using erubis (2.7.0)
Using rack (1.3.4)
Using rack-cache (1.1)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.3)
Using actionpack (3.1.1)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.1)
Using arel (2.2.1)
Using tzinfo (0.3.30)
Using activerecord (3.1.1)
Using activeresource (3.1.1)
Using addressable (2.2.4)
Installing bcrypt-ruby (3.0.1) with native extensions
Using bundler (1.0.14)
Using orm_adapter (0.0.5)
Installing warden (1.0.6)
Installing devise (1.4.8)
Installing diff-lcs (1.1.3)
Using multipart-post (1.1.3)
Using faraday (0.6.1)
Using faraday_middleware (0.6.5)
Using hashie (1.0.0)
Using rack-ssl (1.3.2)
Using json (1.6.1)
Using rdoc (3.11)
Using thor (0.14.6)
Using railties (3.1.1)
Installing jquery-rails (1.0.16)
Using rails (3.1.1)
Using kaminari (0.12.4)
Using multi_xml (0.2.2)
Using mysql2 (0.3.7)
Using net-ldap (0.2.2)
Using nokogiri (1.4.4)
Using oa-core (0.2.6)
Installing rest-client (1.6.7)
Using oa-basic (0.2.6)
Using pyu-ruby-sasl (0.0.3.3)
Using rubyntlm (0.1.1)
Using oa-enterprise (0.2.6)
Using oa-more (0.2.6)
Using oauth (0.4.5)
Using oauth2 (0.4.1)
Using oa-oauth (0.2.6)
Using ruby-openid (2.1.8)
Using rack-openid (1.3.1)
Using ruby-openid-apps-discovery (1.2.0)
Using oa-openid (0.2.6)
Using omniauth (0.2.6)
Using ruby-graphviz (0.9.21)
Using rails-erd (0.4.5)
Installing rspec-core (2.7.0)
Installing rspec-expectations (2.7.0)
Installing rspec-mocks (2.7.0)
Installing rspec (2.7.0)
Installing rspec-rails (2.7.0)
Using ruby-aaws (0.8.1)
Using simple_oauth (0.1.5)
Using sqlite3 (1.3.4)
Using tlsmail (0.0.1)
Using twitter (1.6.0)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.

なんか色々入って不安になるけど正常終了


■rake rails:updateして設定ファイル類を書き換える
 Overwriteで、元の設定が消えてしまうのでconfigは事前にバックアップしておく

$ rake rails:update
#config/routes.rb
#config/application.rb
#->config.assets.enabled = false
#  trueだとstylesheetのパスがおかしくなる。
#  asset pypelineについては後日調べよう。
#config/environment.rb
#->ルーティング設定が真っ白になってたので、書き直し
#config/environments/development.rb
#config/environments/production.rb
#->ここに定数書いてたのなくなってたので、書き直し
#config/environments/test.rb
#config/initializers/secret_token.rb
#config/locales/en.yml


■ライブラリの読み込み

さっきコメントアウトしたせいでWire::usersエラーとかなってるので正しく読み込む
application.rb
→追記: config.autoload_paths += %W(#{config.root}/lib)
enviroment.rb
→追記: include HogeModule