I’ve recently tasked myself with performing a major upgrade for Webster’s Classroom. It includes both a complete site redesign and an upgrade to the latest version of Rails. We all know its a bit of a pain to upgrade from Rails 2 to Rails 3 but the longer you put off the upgrade the more painful it becomes. The app was written as a proof of concept many years ago and despite its growing user base it doesn’t have a strong enough foundation to allow it to continue expanding. We build it too quick and sloppy years ago and as a result we are testless and in need of major refactoring.
The lack of tests actually makes the upgrade easier in some respects because instead of having to hassle of fixing a bunch of sloppy tests I’m building everything from scratch both the app and the tests. The refactoring needed for this upgrade is like writing the application from scratch anyway. The existing code I’m using more or less as a rough sketch of feature requests and I have full intention of throwing all that code away if it makes sense to in this new context. Instead of trying to upgrade the inline Prototype Javascript to jQuery and UJS piece by piece, I’ve decided its best to just throw all the old Javascript out the window and start fresh. I’m committed to getting as close to 100% test coverage as possible these days so as I’m doing the upgrade and redesign I’m making damn sure there’s proper tests in place this time around.
I’ve upgraded a handful of apps to Rails 3 from Rails 2 already and in the past I’ve started off trying to upgrade within the current code base. I’ve had numerous problems with this approach and unless you’re really meticulous on every single file, you’re going to end up with a bunch of old junk files laying around and likely some missing new ones that you’ll want. This time I’ve taken a different approach and started off with a fresh default Rails 3.1 install and began moving over the legacy code file by file. I’m happy with taking this approach and instead of trying to take my Rails 2 code and upgrade it to Rails 3. Starting with a fresh Rails 3.1 code base and moving over code where it needs to be has given me the chance to move things into places they ought to be like moving code outside of the environment configs and into initializers. If I had just tried to upgrade the old code inline, I wouldn’t have spent the same amount of attention on cleaning up that mess. Once this upgrade it deployable, Webster’s Classroom is going to be in a position to really expand dramatically and rapidly.





