Ruby

http://s.erious.ly

Author Archive

Adding Routes for Tests

I like to be extremely judicious with use of routes. Fewer routes means less memory consumption and fewer confusing magical methods. I always delete the default route map.connect ':controller/:action/:id' (you should too, otherwise all ...

JavaScript gotcha: storing objects in an associative array

I just ran into a tricky gotcha in JavaScript. I was trying to store some objects in an associative array. Based on my experience with Java, Ruby, and other languages, I expected that given code like this: 1 2 3 4 5 6 7 var dict...

Sprinkle: the provisioning tool for people who don’t have huge server clusters

I’ve recently been trying to find a good server automation tool that meets my needs. I looked at Chef and Puppet. They are both awesome for what they do, but what I don’t like is all the infrastructure I have to maintain to run...

Announcing VeloTweets, Pulse of the Peloton

I’m pleased to announce VeloTweets, the pulse of the peloton, a curated collection of professional cycling Twitter activity. The idea and driving force came from Jamie Thingelstad. I did most of the development, and Norm Orstad designed...

10 Cool Things in Rails 2.3

This was presented to the Ruby Users of Minnesota on March 30, 2009. Here’s a quick look at 10 new Rails features that I think are cool. Not all of them are huge new features, but instead help solve annoying problems. I’ve also crea......

Dealing with ‘duplicate key violates unique constraint’ on the primary key

I recently had to work through a problem where inserts were failing due to duplicate primary keys. Here’s the error (edited for clarity): PGError: ERROR: duplicate key violates unique constraint "contracts_pkey": INSERT INTO "contr...

Today’s hard-won lesson

An float subtracted from an integer results in a float. When typecast by ActiveRecord, this is converted to an integer. validates_numericality_of with :only_integer => true results in a rather obscure error message if a non-integer i...

Fetcher moved to GitHub

A quick FYI for those who have been using the Fetcher plugin that we wrote (and use on FanChatter Events)... I have moved the Fetcher plugin repository to GitHub. You can get it at git://github.com/look/fetcher.git Happy forking! ...