Jim Lindley Notes

January: Month of Ruby 1.9

January 10th, 2008

[UPDATE: I’ve been terribly sick the last week so this series is delayed a bit, sorry!]

In January I’ll be running a series of posts – one each weekday – highlighting a new feature or change in Ruby 1.9, which had a developer release on Christmas Day. While Ruby 1.9 should not yet be used in production, it is now the perfect time to install it alongside 1.8 and get your hands dirty.


Getting Ruby 1.9


On a Linux/Unix/Mac installation should be straightforward if you are used to compiling packages.

Download:

mkdir ~/src
cd ~/src  
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.0-0.tar.gz
# or curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.0-0.tar.gz
tar xzvf ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.0-0.tar.gz

Install:

cd ruby1.9.0-0
autoconf
./configure --prefix=/usr/local --program-suffix=19
make
sudo make install

Now in addition to ruby, irb, and ri you should have available to you ruby19, irb19, and ri19.

Start up irb19 and check the ruby version:

jlindley$ irb19
>> RUBY_VERSION
=> "1.9.0"

Don’t expect to be able to run Rails and all your usual programs as normal, there is still a lot of work going on updating Rails and other gems to be 1.9 compatible. This release breaks some old things, but going forward 2.0 and further should all be compatible with 1.9. This is the painful release.

So, install 1.9 and check back on January 1st for the first entry in this series. In the meantime, a summary of changes in 1.9 can (sometimes) be found at Eigenclass.org.


Series Index


This section will be updated with links as the month progresses, but an outline of topics is:

Week 1

[UPDATE: I’ve been terribly sick the last week so this series is delayed a bit, sorry!]

WNY Ruby User Group

December 29th, 2007

If you are in Upstate NY, consider checking out the WNY Ruby User Group. Our next meeting is going to be held on January 7th.

Ruby Rags

December 17th, 2007

Ruby Rags, themed t-shirts. I bought this one:

Enterprise Ready

RubyConf 2007 Videos Up

December 15th, 2007

The videos of the Ruby Conf 2007 sessions are up, come of the best to check out are:

Unfortunately, only part of the most memorable session at Ruby Conf 2007 - Hurting Code for Fun and Profit by Ryan Davis - was recorded.

Rails 2.0 Released

December 7th, 2007

Just saw it was tagged in the Rails dev subversion repository. Long time coming but definitely worth it, I’ve been running on edge for 6 months now and Rails 1.2 is hard to go back to when I need to work on older projects.

Official announcement and an overview of changes.

Rails 2.0 Installation


The actual release version is 2.0.1, 2.0.0 had a small issue. EDIT 12/16: the latest version is now 2.0.2. To install it as a gem:

sudo gem install rails

Or inside an existing Rails project:

rake rails:freeze:edge TAG=rel_2-0-2
rake rails:update


Online Resources:


Books with Rails 2 content:


Cookie Security for Rails 2.0

November 20th, 2007

Ruby on Rails Security has a great article on cookie-based session storage. This is the default for Rails 2.0, and if you generate a new Rails app it will create a very long random string to use for hashing the cookie to prevent tampering. This seems to be fairly secure, although it’s always safest to switch to a server based session storage mechanism.

If you are converting your pre-2.0 app to use cookie based sessions, you must be careful to pick a very good secret for the hashing function. And ‘good’ means computer generated, very long, very random, and no dictionary words. Rails will now prevent you from using a secret less then 30 characters long.

If you are only storing a minimal amount of information in the session (such as a user id and flash message), cookie session store is an awesome win. Otherwise, you’re probably using it wrong: no sensitive information should be placed in session, and if you need to expire sessions, you must place an expiration time in the session and check that per request and decide if you’ll accept it still.

UPDATE: More info on cooke session store security.

An awesome set of plugins, one to allow use of Quick Look inside of TextMate’s drawer, and another to enable source code files in the rest of the system to be previewed in formatted glory thanks to TextMate’s parsing.

Quick Look and TextMate, thanks to CiarĂ¡n Walsh.

Git Server Setup

November 14th, 2007

Rails 2.0 Release Candidate

November 9th, 2007

A release candidate for Rails 2.0 has been tagged - see announcement of install directions and other news.

Merb 0.4.0

November 7th, 2007

If you’re looking for a lighter-weight web development framework then Rails, this is Merb is the place to be.

Merb has just released 0.4.0, a release which came about after much love at RubyConf last week. There is now an official Merb site, Merbivore. Check out the list of new features.

There is a bug in the email account activation code, and you should upgrade to the latest version of the plugin.

Leopard and Ruby (DTrace!)

October 25th, 2007

Leopard (Mac OS X 10.5) comes out tomorrow, and here is a list of what that means for the system’s included Ruby from the folks at Apple’s Mac OS Forge.

Nice irb support, and Ruby updated to 1.8.6, Rails 1.2.3, and Mongrel 1.0.1.

The only thing in the list given that surprised me was that the default Ruby install includes DTrace probes. The Ruby DTrace probe patches are based on Joyent’s work on Ruby for Solaris. This is a great way to look inside your app and see what’s really going.

Instruments is the name of the program you use to see what’s going on via the DTrace probes, new in Leopard. Some DTrace examples with Ruby are on the Joyent site (just hit cancel when asked for authorization), and some more examples in /Developer/Examples/Ruby/DTrace in your Leopard install.

UPDATE: Additional info on DTrace in Leopard. If you know of any more sites with detailed info or instructions, please leave a comment and I’ll add to this list.

via Application Error

Rails 2 Mini-Book

October 17th, 2007

Ryan Daigle has created a PDF that covers many of the changes in Rails 2.

It’s $9 and sold through PeepCode. Check it out, if you need to catch up.

Database Adapter Gem Location

October 1st, 2007

DB Adapter Gem status for ActiveRecord announcement on the Rails Blog. Only MySQL, SQLite and PostgreSQL adapters are included in the default Rails 2.0 distribution.

Other adapters can be installed by calling:

gem install adapter-name

The available ones are:

activerecord-firebird-adapter
activerecord-frontbase-adapter
activerecord-openbase-adapter
activerecord-oracle-adapter
activerecord-sqlserver-adapter
activerecord-sybase-adapter

Auto Migrations

September 23rd, 2007

Not in edge rails, but a plugin:

Turning the usual course of events on its head, with the Auto Migrations plugin, you directly edit your schema.rb, and let Rails figure out how to get from here to there. You can also dump your changed schema into a migration file to be run as normal. Supports indexing, too!

rake db:auto:migrate

It’s my new best friend.