January 15th, 2009

Here is a summary of a few of the problems I encountered while trying to upgrade an app from rails 2.1 to rails 2.2.2

Getting my dev code to run

First, to update the rails code:

 > rake rails:freeze:gems

The first time I tried to run the app I got this error:

vendor/rails/activesupport/lib/active_support/dependencies.rb:445:in `load_missing_constant': uninitialized constant Inflector (NameError)
Accessing the inflector changes, so as described here you need update APP/config/initializers/inflector.rb so it looks like this:
ActiveSupport::Inflector.inflections do |inflect|
  ...
end

In my case, I was also using the ActiveMerchant plugin which needed updating for the same reason

script/plugin install git://github.com/Shopify/active_merchant.git --force

According to gusg.us, HAML needs to be at 2.0.4.   I didn’t see any problems in my testing but I didn’t want to try my luck so I updated HAML too.

sudo gem update haml

update my environment.rb gem requirement

config.gem "haml", :version => "2.0.6"
Then run
rake gems:unpack:dependencies

Production

While deploying to a staging server I got this error:

initializer.rb:514:in `send': undefined method `cache_template_loading=' for ActionView::Base:Class (NoMethodError)

As described here, to fix this, just update your APP/config/environments/production.rb (and staging.rb) file by removing the following:

config.action_view.cache_template_loading

Overall, it wasn’t too painful an upgrade…

I didn’t run rake rails:update. That may have fixed some of these things on it’s own, but my understanding was that that wasn’t needed anymore…

Tags: ,

7 Responses to “Upgrading an app from Rails 2.1 to Rails 2.2.2”

  1. faith says:

    Wow gross. I wish it weren’t so painful…

  2. Geoff says:

    It wasn’t painless, but it was actually pretty easy. Only took about 40min….

  3. Abhishek says:

    Thanks Geoff. Due to your help I could quickly do the migration.

  4. Tony says:

    Ahh, those pesky plugins….
    Thanks for reminding me.

  5. Tony says:

    Follow up:
    Even though the migration worked with the above, my mysql broke.
    If you have this issue, follow this thread, which did the trick for me:

    http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/399a51529e9f75a1

    You’ll need to do BOTH the mysql update as well as the name_tool thing….

    Cheers!

  6. [...] That’s it! It overall was a very easy upgrade that took much less time to test than my rails 2.1 to rails 2.2.2 upgrade. [...]

  7. Thanks for the tip. It helped me to upgrade from Rails 2.1.0 to Rails 2.3.2 – it was pretty much same procedure.