At TeamSnap, we’re preparing to upgrade our code base from Rails 2 to Rails 3. To get some practice with this, I’ve been working on updating the Klang app that I maintain. The guys at Airbnb have an excellent account of their own experience. All of their advice is very good. I was lucky in that I had already done step 1 (move to Bundler) and step 2 (add the rails_xss plugin) - in fact, I did rails_xss about two years ago, when I thought I would get to the rest of the Rails 3 upgrade soon. That didn’t happen, but it did mean a lot of the really hard work was done when I started the upgrade in earnest.
There were tons of deprecated features that I had to address. Most of them were no big deal. Learning the new ActionMailer API took a bit of head-wrap-around, but in the end it wasn’t a problem. The biggest problem was that Shoulda just failed horribly in all of my functional tests (yes, I’m still using good old Test::Unit, not rspec - that’s a paradigm shift for another day.) The unit tests were fine, but the functional tests that had run perfectly under Rails 2 broke inconsistently under Rails 3. In the end, I ended up rewriting the functional tests to not use Shoulda, and ran those tests instead. When everything else was working, I put the Shoulda-fied tests back in, and they worked fine. I spent a few hours de-Shoulda-fying the tests, but I’ll chalk it up to a useful learning exercise.
One thing that bit me was several of my “destroy” links on the admin side simply failed to work. This was my own damn fault; I should’ve been using form submissions to do these all along. As often happens, Stack Overflow pointed me in the right direction and I replaced all the link_tos with button_tos. That fixed that.
So at this point, I’ve got the application running on Rails 3.0, with all of the tests passing, and it works well in development mode on Pow. The next step will be uploading this to a new app on Heroku, alongside our existing Rails 2 app, and pounding on it for a while. But it all looks good right now.
Once this is done, moving to Rails 3.1 is the next step. We don’t do a lot of JavaScript at Klang, but we’ve got some, so the asset pipeline is likely to be our biggest challenge. And from there, who knows… maybe we’ll all be on Rails 4 by then?