Installment 2 of my upgrade from Rails2 -> Rails3
Ack – I depend on all these gems!
I spoke with a co-worker about this. He’d been through the upgrade and mentioned that Gem upgrades was a major part of the move from Rails2 -> Rails3.
As I mentioned before, I’d taken steps to get my app as close to Rails3 ready as possible (read installment 1). Now it was time to pull the trigger.
I updated my Gemfile to require
gem "rails", "3.0.20"
bundle update rails
I immediately ran into issues. Out of date gems!
Since I was moving forward, I decided to do a full
bundle update. This would force everything (within dependencies) to the latest. I then could go back and figure out issues. In the end, I had to pin a few gems down. I got to upgrade a few. I had to dump a few. And the rest (at least at this point), look like they’ll work out as is.
gem 'nokogiri', '~> 1.5.0' # At 1.6.0, this gem is no longer ready for 1.8.7. Pin it to 1.5.x.
gem 'gibbon', '~> 0.3.5' # mailchimp api
gem 'browser', "= 0.1.6" # 0.2.x does not support ruby 1.8.7
gem 'dalli' # now I can use 2.x
gem 'rspec' # now I can use 2.3.x
gem 'will_paginate' # move up from version 2.3.16
Moved mobile-fu to mobile-fu-rails3
Removed (looking for replacements)
Of those removed, I should add a few notes.
This one caused me all kinds of headaches. I did some searching and was able to find a replacement (here) that said it was Rails3 ready. I neglected to read the not so fine print from the README
This is a hacky attempt to port has_many_polymorphs to work under Rails 3. It is intended solely for my use (and use as a gem) but is offered here in case it helps anyone else develop it into a more complete port.
After sticking this into the Gemfile (and doing some other mods), my test suite started failing hard.
has_many were failing on class load. I tore my hair out for a bit (read more here). Then some deep debugging revealed that the
has_many_polymorphs update was Rails3.2 compatible, but not Rails3.0.
I’ve torn it out completely. It was relatively easily replaced by using the
:polymorphic setting for Rails associations. You can read more about that here.
ym4r is not a gem, it’s a plugin. At the time I’d built this site, we wanted a map of
geokit-rails with a the
Ym4r_gm plugin, I could generate a Google Map from ruby and drop it on the view. It seems that the Ym4r plugin has fallen away in favor of
Google Maps For Rails. For now, I’ve decided to live without the Map (it’s only one page) until I get to Rails 3.2 and then I’ll check my options. I may just write the client side (JS) integration from scratch with Googles JS api. Less dependence on gems.
Other gem related mods
While making all these changes, and trusting my test suite, I decided to make a few more updates.
mocha which I was using for mocking in tests. The new
Rspec does a fine job with
Double and has good support for stubs. This meant combing through my specs replacing:
MyModel.any_instance.stubs(:method => val)
MyModel.any_instance.stub(:method => val)
I also installed a much needed
rcov to get some sense of my test coverage. I was able to stick this on the Rails2.3 branch and the Rails3.0 branch to validate that in all my mucking around, I hadn’t lost any tests. Happily, the old branch was 89% covered (not too bad, considering this was my Rails learning project). And I was able to validate that after updating tests to not rely on
mocha I still had 89 percent coverage. In fact, in the process, the coverage went up, because I did some code-cruft clean up and added tests in a few spots.
As I find out more, I’ll scribble some more notes. Though these posts maybe a bit sloppily written, I hope they save a few folks out there who may still be going through this upgrade a headache or two.