Monday, August 10, 2009

RailsRumble '09

 I plan to participate in this year's Rails Rumble with team Agile Nomads on August 22nd.

Friday, February 06, 2009

Acts as Conference coverage on Ruby Rails Review

Thursday, January 08, 2009

Ruby tip to handle missing records

Here's quick and simple tip to cleanly handle non-existent records in Ruby.

By default if you try to use find(id) to fetch a record from your database and the id doesn't exist you'll get a RecordNotFound error like:


>> r = Record.find(9999)
ActiveRecord::RecordNotFound: Couldn't find Record with ID=9999
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:1383:in `find_one'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:1366:in `find_from_ids'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:541:in `find'
from (irb):3

You could wrap it with a begin and rescue and have the rescue clause create a new record such as:

begin
r = Record.find(id)
rescue
r = Record.new
end

Or you could simply use find_by_id which will return nil if the record is not found and re-write it as:

r = Record.find_by_id(id) || Record.new

Tuesday, December 23, 2008

Merb and Rails Merge

The competing Ruby frameworks, Rails and Merb, have decided to join forces!

Here is the announcement from Rails creator David Heinemeier Hansson and the similar announcement from the Merb perspective from Yehuda Katz.

Keep up with all the latest Ruby and Rails news at Ruby Rails Review.

Tuesday, December 16, 2008

Ruby on Rails News Site

I haven't been very active on this blog recently, but I've been keeping plenty active on other endeavors. One of which is the Ruby Rails Review which my friend, Brian Burridge, announced last week. As he mentioned in the announcement I created a very easy to use CMS tool which allows us to drag-and-drop the news stories all over the page for placement (or addition and removal), as well as a bookmarklet to simplify the process of adding new stories. I've very happy with how it turned out, unfortunately no one gets to see it but he and I.