The past few months, among normal work stuff, I’ve been busy working to convert an old (5years and running) app from Rails 2.3.x to Rails 3 with the hope of finally getting to Rails 3.2 and Ruby 1.9.x.
It’s been a bit of an uphill slog, as you might imagine.
I’m going to start scribbling some of my notes here in the blog in a series of posts in hopes that others don’t rathole on the same issues that I struggled with.
After a chunk of reading online (much thanks to the airbnb post), I started by trying to update the codebase without updating Rails so that when I did move, I’d have as much of the simple stuff resolved in the Rails2 branch.
Step 1: rails_xss
I started by installing the
rails_xss gem. This switches the default view generators to escape strings which is inline with what Rails3 views do.
I added to my Gemfile :
Thankfully, I had a pretty strong view test suite and was able to find and fix issues based on my test failures.
Step 2: Dump RAILS_ROOT
This was pretty much a search-replace task. Replace
Step 3: include jQuery with noConflict
This app was still on PrototypeJS. It seems like it’s finally time to make the move. The first step is to simply get jQuery in the codebase with noConflict. This will allow me to convert, over time, the Prototype plugins and code to jQuery without having to move it all in one chunk.
This was pretty straight forward. Add the jQuery source from http://jquery.com/ and include it in my HAML layouts like so (at the top, before including prototype and other library js):
With these mods, and getting my test suite sorted out, I was able to push out a new version still on Rails 2.3.x but much closer to being Rails3 ready that it was before these mods.
I’ll continue to add notes in subsequent posts.