Posts Tagged ‘ruby 1.9’

Ruby 1.9.1 & Friends

Saturday, January 31st, 2009

I have made a followup postto this which contains more up-to-date information. This post is left here as an example of the state of Ruby 1.9 in January-July 2009.

Last updated: July 11th, 2009

For changes between Ruby 1.8 and Ruby 1.9, look here

So this morning I sat down to give Ruby 1.9.1 a shot with my goal being to get at least the very, very basic Rails application running on it. I’ve run this guide on Mac OS X. Your mileage may vary.

Ruby 1.9.1

Download it from the ruby-lang.org website, install it using autoconf && ./configure –with-readline-dir=/usr/local –program-suffix=1.9 && make && sudo make install and everything should be peachy. I’ve gone about installing Ruby 1.9.1 alongside my current installation of Ruby. If you wish to go the “whole hog” (and I don’t recommend that you do, unless you know how to revert it) don’t run the configure command with the –program-suffix option specified.

Rubygems

Since Ruby 1.9.1 comes with Rubygems now, and this has been confirmed to Just Work ™. The command used was gem1.9.

Rails

gem1.9 install rails rack sqlite3-ruby works too, which is nice to see. The versions of the things installed were:

  • Rails: 2.3.2
  • Rack: 1.0.0
  • Sqlite3 Ruby: 1.2.4

You need the rack gem for running your Rails app and of course the sqlite3-ruby gem because, by default, Rails applications use sqlite3.

The Rails App

We’ll generate a Rails application by typing rails onepointnine and we’ll head into this directory.

Because I’ve installed 1.9.1 alongside 1.8, the version that Rails will try to use by default is 1.8. To fix this, we’ll be running our commands with a ruby1.9 prefix.

We launch our server by ruby1.9 script/server and then go to http://localhost:3000. Welcome aboard! Clicking on “About your application’s environment” should give you something like this. If you don’t see Ruby 1.9.1, you’re using the wrong version of Ruby. Ensure that you launched the server with ruby 1.9 script/server

In another tab, we run ruby1.9 script/generate scaffold blog title:string text:text to get our scaffold and rake1.9 db:migrate to put some tables in our sqlite3 database. Now go to http://localhost:3000/blogs and play around a bit. Everything at this point should be working.

(more…)