Upgrading Assistment to Rails 2.0

16 Dec 2007

image linked from b.lesseverything.com
Today I spent some time upgraded Assistment (http://assistment.org) to Rails 2.0. I made the mistake of upgrading Rails before changing anything, and then fixing the errors one by one ... oy. So, I'll quickly go over what I had to do to get stuff working again.
Fix deprecation warnings in 1.2.6
If you haven't upgraded yet, make sure you're on Rails 1.2.6 and get rid of your deprecated API calls: http://www.rubyonrails.org/deprecation. To easily find your deprecated usages grab the rake task from this site: http://www.slashdotdash.net/articles/2007/12/03/rails-2-upgrade-notes. And of course, make sure your tests pass and your app actually runs before moving on!
Keep in mind some pretty useful parts of Rails have been pulled out into plugins, which you can find at http://svn.rubyonrails.org/rails/plugins/. I had to install acts_as_list, acts_as_tree, classic_pagination (though, we really need to move to will_paginate!), and in_place_editing. I also had to spend time updating my forms to use the block-notation rather that start/end form tags. That was annoying. One plugin I had trouble with was acts_as_paranoid. It calls construct_count_options_from_legacy_args, which is deprecated, but I have not found an update to the plugin. To fix it, I had to add that method to the plugin. I left the deprecation notice in there to remind me to fix it =) Also, if you used strip_tags in your model (shush, I had my reason: I used it since I stored HTML in the database and I wanted a nice way to clean it), you have to include ActionView::Helpers::SanitizeHelper in your model; just including ActionView::Helpers::TextHelper won't cut it.
Upgrading Rails
gem update rails
should do the trick for upgrading you. I had some problems upgrading on Leopard, so I had to gem remove rails and the active*/action* gems before running "gem install rails". Even that failed the first 2 times with 404 errors for finding certain gems, but the 3rd time it worked.
rake rails:update
Run that in your project to upgrade your configs, javascripts, and scripts. I took the extra step and generated a new rails project and merged any new config changes into Assistment. This was mainly environment.rb, and the extremely useful addition of a initializers directory for application config.
Running Two point Oh!
(Note: to use ruby-debug you don't need to manually set it up in environment.rb. Simply run ./script/server --debugger to enable debugging with the "debugger" method. Yep, that simple.) Run your app/tests and your on Rails 2.0! If anyone has any additional issues, google is your friend.
comments powered by Disqus