CNK's blog

Upgrading Rails 2 to 3

A few security releases ago, I converted my Rails 2.3 site to using bundler (and while I was at it, vendored all the gems I am using). This made subsequent security updates much easier. But now that Rails 4 is out, there will be no more security releases/backports for the Rails 2 series. And there have been some recent security releases for Ruby - which are only officially being added to Ruby 1.9 and above (though Heroku is continuing legacy support for 1.8.7 for a little while longer). Which makes it really, really past time to upgrade.

I intially tried installing ruby 1.9.3-p484 with my current rails 2.3.18 gems but I had trouble installing rmagick. RHEL 5 has an older version of ImageMagick so I need to use rmagick 1.15.17. To get rmagick to build on the new ruby I needed to move to RHEL6 so that I could get ImageMagick > 6.8.2 which I needed to move to rmagick 2.x. So I set up a quick Vagrant VM with CentOS 6.4 and got everything installed. However I had some trouble running my functional tests so I decided to fall back and try upgrading my rails version before upgrading my ruby. So as with all things Rails, the logical first step is Railscasts.

My development server has RVM on it. My default ruby is the ‘system’ ruby - REE-1.8.7-2009.10 with rails 2.3.18. Wth that combo, all my unit tests and cucumber features pass. So I installed rails-upgrade as a plugin, script/plugin install git://github.com/rails/rails_upgrade.git The plugin contains a task to backup some stock files that will be overwritten when I run rails new . in my CMS repository: rake rails:upgrade:backup

Then I need to set up Rails 3. I don’t want to deal with changing my REE in /opt so, I used the REE installed via RVM, ree-1.8.7-2011.03. I created a new gemset, rails-3.0 and installed bundler in it. Then changed the rails version in my Gemfile to 3.0.20 and ran bundle update. Then I upgraded rails using rails new ., accepting all of the requests to overwrite files. Then I started working my way through the changes I see with git status.

Ughhh horribly broken - can’t even run tests from this state.

Comments