Upgrading from Rails 2.0 (ish) to Rails 2.2

Look out – this post is going to be a bit dry.

Over the Thanksgiving weekend, I upgraded Ravelry from a crusty old nearly-2.0 version of Edge Rails to the latest 2.2.2. Other people’s upgrade war stories were really helpful so I figured that I’d post my own. (See also gusg.us’s 2.2 story, assaydepot’s 2.1 story)

Here are the things that had to be fixed or tweaked:


environment.rb
I moved a bunch of stuff out of here into the config/initializers directory. Much neater. I also config.gem‘d my gems.
cache_fu plugin
Broken. Upgrading to the latest source from github made it all better.
memcached gem
I use Evan Weaver’s juiced up memcached client. Upgrading to the latest source from github made it all better.
xss_terminate plugin
I’m using xss_terminate for sanitizing input and I needed to add a little patch to an initializer to make the plugin work properly: http://code.google.com/p/xssterminate/issues/detail?id=3#c0
exception_notification plugin
Wasn’t working right, but I’m using HopToad now so I just trashed it.
acts_as_versioned
I read that weird stuff would happen with older acts_as_versioned and the new dirty attributes/partial updates. Upgraded to the latest source. Unfortunately, the newer version seems to handle version columns differently. I was previously using “acts_as_versioned :version_column => ‘lock_version’” to base the “version” column in the versioned table off of the model’s “lock_version”. Now it wants both to be called “lock_version”. I just patched it for now.
RFPDF plugin
Broken. Changed init.rb from ActionView::Base::register_template_handler 'rfpdf', RFPDF::View to ActionView::Template::register_template_handler 'rfpdf', RFPDF::View
rails_asset_id in ActionView::Helpers::AssetTagHelper
Gone. Reworked some helper code – I didn’t need it anyway.
attachment_fu
Broken by ActiveRecord changes. Here is the fix: http://ar-code.lighthouseapp.com/projects/35/tickets/25-edge-callback-overrides-inconsistently-pass-arguments
active_form
More small breakage. Here is the fix: http://github.com/valda/active_form…
has_many_polymorphs plugin
Oh god – has_many_polymorphs was a nightmare (as expected). I upgraded to the latest and then had to fix broken stuff for a while. I don’t know what version I was using before but stuff changed. ack.
prototype.js
Sadly, I’m still using a pre 1.6 version of Prototype and now was not the time to upgrade that as well ;) I had to implement Element.Insert in Javascript because the RJS stuff was changed to use that instead of Insertion (which was deprecated) You can see the change that I’m referring to here: http://github.com/rails/rails/commit…

That’s it! Also, HopToad was a great help in finding a few small bugs and glitches once I pushed the upgraded version out to production.

Now what?

I’m going to go back to fun Ravelry-improving work for a while. Still, I’d like to move to Git. …and maybe take the latest JRuby out for a test-drive. The total amount of memory that our Mongrels (Thins) consume is pretty embarrassing and things are heating up in the JRuby world with faster releases, a more threadsafe Rails, and so on…

Toolbox photo from Flickr/mamabarns .

Comments (5)

  1. Victor wrote:

    Just out of curiosity how large do your mongrel servers get on average? How many of them do you run? And if you don’t mind disclosing but how much traffic per day actually hits the mongrel/rails process do you estimate?

    I interested in the resource requirements of Rails/RoR under traffic.

    I remember you mentioned that you get a ton of calls to your ravelry API. Does Activerecord perform adequately since it has nothing like hibernate’s second level cache?

    I am actually thinking of dabbling with Rails once again since JRuby has matured and Rails is thread safe.

    Monday, December 8, 2008 at 9:49 pm #
  2. Thanks a lot for this blog post,

    I managed to create the initializer so that xss_terminate can correctly load in production mode.

    Have you tried mod_rails VS Nginx+HAProxy+Thin?

    On our VoD website, we use Nginx+Thin only.

    I will follow your blog closely.

    Best regards and happy new year

    Thursday, January 1, 2009 at 4:18 pm #
  3. casey wrote:

    (Pasting my email response to Thomas)

    Happy new year to you!

    We actually switched to mod_rails about a month ago. I’m happy with it for the reasons that Tobias describes here: http://blog.leetsoft.com/2008/11/15/passenger

    However, there are a couple difficulties:

    First – it crashes from time to time. I don’t know why. http://code.google.com/p/phusion-passenger/issues/detail?id=174&colspec=ID%20Type%20Status%20Priority%20Milestone%20Stars%20Summary

    This isn’t as big a problem as it would be for many people because I am running 6 passenger+Apaches and still using HAProxy. If one crashes, we get an email alert (thanks to Nagios), the site is not affected (because HAProxy starts ignoring it) and I restart it when I have a chance.

    The second issue is that I had to create a more complicated Capistrano deploy script to deploy applications. This is because we were having lots of problems when deploying while Passenger is running so I had to set up Capistrano to remove each server from the load balancing, stop Apache, deploy the application, and restart. At least one other person confirmed this problem:

    http://groups.google.com/group/phusion-passenger/browse_thread/thread/954171096e17c6f5/95ecc5b5cd6fb843?lnk=gst&q=restart#95ecc5b5cd6 fb843

    Now that I have something that works, this is no trouble at all. If the random crashing was fixed that I’d be very happy with this setup.

    Thursday, January 1, 2009 at 4:42 pm #
  4. Thomas wrote:

    Hi Casey,

    Thank your for your reply. I will probably give mod_rails a try. However we will still keep Nginx as we heavily rely on it for streaming protected video content.

    Best wishes,

    Friday, January 2, 2009 at 9:59 am #
  5. Hi, thanks for using xss_terminate.

    Sorry it took so long to reply to your issue in the tracker – I just realized today that it is not set up to email me new bugs!

    Anyway, I have fixed the incompatibility with Rails 2.2, while still being backwards compatible with Rails 2.0 and 2.1. You can get the new code from the GitHub repository:

    http://github.com/look/xss_terminate/tree/master

    Friday, January 2, 2009 at 3:38 pm #