Rails on Ruby 1.9.1 in production: just do it

Jan 10, 2010 by Andre

Two of my side projects, shapewiki and hotspotr are now running in production on Ruby 1.9.1. There are some good resources out there for getting familiar with Ruby 1.9. I wanted to share a few tips/observations on the upgrade process.

Gem/plugin compatibility: not really an issue on the two projects I deployed. Obviously, your experience will be a case-by-case depending on the gems/plugins you use. My takeaway was that the apprehension of dealing with this was far worse than actually dealing with it. The worst case was having to seek out a newer version (acts_as_versioned) or swapping in an alternative (nokogiri). Some of the gems/plugins I dealt with were:

  • authlogic: ok
  • geokit: ok
  • acts_as_versioned: ok, I had a pretty old version and updated it to: http://github.com/technoweenie/acts_as_versioned/tree/master
  • hpricot: seemed ok until I ran into run-time issues, had to switch to nokogiri. Which turned out to be very easy, essentially no code changes. Note: I did this part six months ago, and haven't checked hpricot since, so it may be fine now.
  • haml: ok
  • mislav-will_paginate: ok

Local development environment: there's just one thing you need to know: RVM. RVM makes it incredibly easy to install 1.9 and switch back and forth frictionlessly. And if you're concerned about messing up your working-just-right current system, don't be: you can revert back to your original setup in one command, or remove all traces of RVM whenever you want to. But trust me, you won't want to. RVM is awesome. Install it now so you can start doing the right thing.

Character encoding issues: this is what kept me off of 1.9 for quite a while. I initially got a few applications running on 1.9 six months ago, but ran into problems in production with extended characters from existing production data. Here are the fixes that finally got me up and running: http://gist.github.com/273741. Just drop this into your Rails app as confit/initializers/ruby_191_hacks.rb and you should be good as long as your database content is stored as UTF-8.

Ruby 1.9.1 in production: I took the shortcut of just using RVM to install Ruby 1.9 in production as well. A dedicated installation probably makes sense in the future, but the RVM installation works fine for now.

I feel strongly that building & maintaining momentum on Ruby 1.9 is important for the Ruby and Rails communities. The important thing to know is that it's not hard. RVM makes it very easy to dip your toes. Gem and plugin compatibility is very good at this point, and getting better all the time. So go ahead, install RVM and start the process. Once you've upgraded your app or got a new gem working on 1.9, put up a quick post or tweet on it. Every bit helps us move forward as a community!

Comments

1

Chris on Jan 27

How would you run several 1.8 ruby apps along side a 1.9 ruby app within passenger?

2

codesnik on Jan 18

sorry for commenting such an old post, but have you experienced problems with profiling?
my current app is 100% working on 1.9.2rc2, but I have segfaults somewhere in the middle of nokogiri internals when using ruby-prof. this draws me back from switching my production setup and all my devs to 1.9

Post a comment

 
This is so filters can reject the spam-bots. Thanks!