Rails 2.3.2 upgrade gotchas

Matt Jankowski

With the latest stable release of rails out the door for about a month, we’ve had a chance to upgrade the bulk of the applications we maintain to 2.3.2.1. The rails 2.3 release notes were a HUGE help during this upgrade. Thanks to the Mike Gunderloy for compiling that document.

''

Here are some gotchas, aka issues, aka roadblocks to Strategic Enterprise Adoption that we discovered while upgrading some of them.

Upgrade Hoptoad

Problem: ‘const_missing’: uninitialized constant CGI::Session (NameError)

Solution: Hoptoad Notifier plugin needs to be updated.

ruby script/plugin install --force git://github.com/thoughtbot/hoptoad_notifier.git

Rename application controller

Problem: You see 'load_missing_constant': uninitialized constant ApplicationController (NameError).

Solution: You need to rename application.rb to application_controller.rb.

CGI::Cookie

Problem: @request.cookies["name"] = CGI::Cookie.new("name", "value") sets the cookie to [value] instead of value.

Solution: You no longer need to set the cookie to a CGI::Cookie instance. Just set it to the string directly: @request.cookies["name"] = "value".

Transactional Fixtures

Problem: You see an undefined method 'use_transactional_fixtures=' for Test::Unit::TestCase:Class (NoMethodError)

Solution: In your test/test_helper.rb file, you need to rename Test::Unit::TestCase to ActiveSupport::TestCase to set these options.

Routing tests

Problem: You see `NoMethodError: undefined method ‘assert_recognizes’ for

RoutesTest:0×22058f8`.

Solution: Are you testing your routes in a unit test with a class of ActiveSupport::TestCase? The routing assertions are only included in ActionController::TestCase now, so change the test class to use that instead.

Count through associations

Problem: errors on a #count that goes through a named_scope on a has_many :through. This used to successfully proxy through and run a successful SQL COUNT query. Now there’s all this.

Solution: not sure yet, maybe use the file at the end of that ticket?

Upgrade rake

Problem: when you deploy to staging or production, you get an error about an undefined reenable method on Rake::Task.

Solution: This method was introduced in rake 0.8.2, but not actually used by rails prior to the 2.3 release. You need to update rake to a version newer than 0.8.2 on your servers (0.8.4 is latest stable as of now).

Upgrade rubygems

Problem: When deploying you get an undefined method ruby_version for Gem:Module error.

Solution: Upgrade rubygems to the latest stable version (1.3.1 at the time of this post).