Posts Tagged ‘ruby’

Multiple Ruby Versions for Development

10 September 2009 by Bret

We’ve been working through bug after bug in Ruby 1.9.1 and Rails 2.3.4 all in the effort of getting our new product launched. I don’t want to say we’ve given up and retreated, but rather, we’ve put Ruby 1.9.1 to the side for a while. There are just too many things that need patching and fixed just to get things to run normally.

We’re looking at Ruby Enterprise Edition by Phusion, and we’re pretty excited by the features and speed. We just want to go back, either to 1.8.7 or even 1.8.6 cause outside of 1.9.1 not only do normal things work, like sending an email from someone: John Locke < jlocke@theisland.com > instead of just a nondescript email address: jlocke@theisland.com But the site just seems way faster than when it was on 1.9.1.

To downgrade my development Ruby and make like easier when we want to return to 1.9.x, I turned to Ruby Version Manager. RVM is a great little gem written by Wayne Seguin that was just updated yesterday. RVM allows you to switch between Ruby versions, including Ruby Enterprise Edition and JRuby as well as using what RVM calls gem sets.

This allows me to install different versions of Rails against a particular version of Ruby. For example, by just typing: rvm ree -m rails234 I can set up a gem set called rails234 where I can install Rails 2.3.4 using gem install rails -v 2.3.4 and test it using Ruby Enterprise Edition. If I want to install Rails 2.3.3 I do the same thing: rvm ree -m rails233 then gem install rails -v 2.3.3

Switching between versions is as easy as rvm ree or rvm 1.9.1 You can find out more at the RVM site. But I have to say Ruby development has never been so easy. Thanks for a great gem Wayne.

Ruby on Rails 2.3.4 not playing well with Ruby 1.9.1

6 September 2009 by Bret

I was hoping upgrading from Rails 2.3.3 to 2.3.4 was going to be a breeze. Nope. Apparently, there are some issues with Rails 2.3.4 and Ruby 1.9.1 as detailed in this lighthouse ticket.

The problem is in the active_support-2.3.4/lib/active_support/message_verifier.rb file. When you try and login to your Rails app you’ll receive an error like:
undefined method `^' for "9":String

I won’t get into the details as to what’s breaking, that’s for those much smarter than I.

Basically if you’re using Ruby 1.9.1, you might be better off not upgrading to 2.3.4 as your application will break. I applied the patch in the ticket and all works now, but what a pain. Seems like something that should have been tested before 2.3.4 was released. Others have had the same issue as well.

To apply the patch I downloaded the patch from the lighthouse ticket above to my desktop and then used:
cd /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.4
sudo patch -p1 < /local/path/to/patch/0001-ruby-1.9-friendly-secure_compare.patch

The file that needed to be patched couldn't be found so i got:
File to patch:
Where I entered the path to the file:
lib/active_support/message_verifier.rb

The patch then applied and I was once again able to login to my application.

File Uploads with Rack 1.0 and Ruby 1.9.1

21 August 2009 by Bret

In our rails application we have a file upload feature. Worked great, until we moved development to Ruby 1.9.1. In Ruby 1.9.1 with Rack 1.0 we ended up with this wonderful little message.

Status: 500 Internal Server Error invalid byte sequence in US-ASCII

Looking at the github source code for Rack we noticed that offending file had been updated, but not pushed out to the 1.0 version of the gem. Why? We’re not entirely sure. The solution was to clone the repo on github into a src directory.

git clone git://github.com/rack/rack.git

Then copy the /lib/rack/utils.rb into the 1.0 gem. Restart the server and there we go, uploads resume their uploading goodness.