Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Author Archives: Peter Cooper

By Peter Cooper / June 3, 2006

Craig Webster has posted several times over the few days about his adventures with sockets in Ruby. He provides nice code examples (even doing socket stuff direct from irb!) and his explanations are useful if you know what you’re doing with Ruby, but haven’t tried doing any TCP or socket work yet:

By Peter Cooper / June 3, 2006

When using Rails it’s easy to forget there’s any other way. Sometimes, however, it’s useful to access databases outside of that environment. Luckily, ActiveRecord can be used separately from Rails, and Craig Webster demonstrates how. Read More

By Peter Cooper / June 2, 2006

Devin Steffler shows you how to load over 100000 countries, states, and towns into your Rails app’s database, from how to get the data to the code to transform the data into database entries. Read More

By Peter Cooper / June 2, 2006

Step 1: Get the Yahoo-Ruby API. It’s only a small Ruby file. Its only dependencies are net/http and REXML that come with Ruby anyway.

Step 2: Make sure you have a Yahoo! API ID. If you don’t, get one now.

Step 3: Use a script like this one from O’Reilly’s Yahoo! Hacks book. The code can be as simple as this: Read More

obj =‘insert app ID’, ‘chunky bacon’, ‘phrase’, 10)
results = obj.parse_results
# results now contains an array of hashes
puts results.inspect

By Peter Cooper / June 2, 2006

Stuart Halloway and Justin Gehtland of Relevance LLC have put together an online presentation called AJAX on Rails. It looks at AJAX, its relation to Rails, how Prototype works, and provides lots of great code examples. If you want to brush up on your whole AJAX and Rails knowledge, it’s worth looking at. A PDF version is also available. Read More

By Peter Cooper / June 2, 2006

An oldie but a goldie.. Kent Siblev had an issue with his Rails application ballooning to 150 megabytes of memory usage per process. He couldn’t figure out where the problem was, so he wrote a small plugin called MemoryLogging to check memory usage on each request (Linux only, I’m afraid). He found his problem within minutes and explains what was going on. Read More

By Peter Cooper / June 2, 2006

The creator of co.mments, Assaf Arkin, a Rails developer, has created a plugin that makes it easy to add a Undo feature to your Rails app. Instead of warning users about things simply let them do it, but give them the choice to undo afterwards. Assaf’s plugin doesn’t cover all the bases, but it’s easy to build upon for creating your own system. For deletion, for example, you’d want to come up with a way to keep the data floating around for a while. Read More

By Peter Cooper / June 2, 2006

Basic Ruby

Advanced Ruby

By Peter Cooper / June 2, 2006

This is a “short” Ruby on Rails reference. It’s goal is to give you an overview over the most used functions / methods / classes. It’s not a tutorial, but as a handy guide when you already know your way around.

The “InVisible Ruby on Rails Reference” is an excellent resource for all Rails developers. It covers models, controllers, views, HTML helpers, ActionMailer, session configuration, etc.. and it’s like the most ultimate, largest ‘cheat sheet’ for Rails. Lots of examples, lists, and references, all organized really well. This is a keeper.

UPDATE, June 6th! This Rails cheat sheet is also pretty good. Read More

By Peter Cooper / June 1, 2006

Sebastian Delmont has put together a great PDF presentation covering most of the different ways to find things with ActiveRecord in Rails. Excellent. Read More

By Peter Cooper / June 1, 2006

Tar2RubyScript is a tool that packages up your entire Rails application into a single tar file with a special loader so that users can get up and running with one click.

The next step is working out how to package up an entire Rails app, database, and WEBrick (or Mongrel) daemon into a single OS X .app folder so that you can distribute cool Web apps to run on people’s local machines. Snippets would be a great candidate for this. I’ll post more information when I figure it out! Read More

By Peter Cooper / June 1, 2006

In this photo, a Ruby script has found the license plate and marked it with a red box (source below).

Camellia is a powerful ‘computer vision’ library you can use from Ruby. It’s written in C, is cross platform, and offers lots of features like color conversion, warping, filtering, drawing, and labeling. Here’s the source code to find the license plate in the photo above:

require ‘rubygems’
require_gem ‘camellia’
include Camellia

# load picture alfa156.bmp

# consider only the V plane (red)

# threshold and encode

# labeling
puts “#{blobs.nb_blobs} blobs detected”

# draw rectangle on all detected blobs
blobs.each {|b| image.draw_rectangle(b.left,,b.left+b.width-1,,cam_rgb(255,0,0))}

# save the resulting picture

# find out the biggest blob
sorted=blobs.sort {|a,b| b.surface<=>a.surface}
puts “The bigger blob is at position (#{sorted[0].cx},#{sorted[0].cy}) and its surface is #{sorted[0].surface}”

Update – May 2007: Paul Battley has worked out how to get this all running on Mac OS X. Read More

By Peter Cooper / May 31, 2006


The creator of Ruby on Rails, David Heinemeier Hansson, has made the cover of Linux Journal. Of more interest is their impressive dedication to Ruby topics this month, another sure sign that Ruby is on the way up.

The nay-sayers have dismissed Ruby in the past, but if it isn’t higher than Python on the TIOBE Programming Community Index (popularity of different programming languages) by May 2008, I’ll eat my hat. Ruby is currently at #20 and Python is at #8. Read More

By Peter Cooper / May 31, 2006

Another new article in Bruce’s series shows you how to get DOM-friendly IDs from ActiveRecord. This is a solution nearly all Rails developers have implemented at some time or another:

<% @entries.each do |entry| %>
<li id=’journal-entry-<%= %>’>
<%= entry.body %>
<% end %>

But Bruce demonstrates a cleaner way.. Read More

By Peter Cooper / May 30, 2006

Bruce Williams has a great set of articles going on on his blog called “Rails Views”. Each one looks at a different aspect of Rails’ views and templates system and how you can use it in a cool or different way. You are bound to learn something or come up with some ideas on how to make your views more efficient (I sure have!). Here are some of the recent posts in the series:

  • Internal Plugins – Bruce demonstrates a great way to separate common functionality in your applications using plugins. Lots of food for thought here.
  • Helpers That Take Blocks – A look at creating your own helps that take blocks, like form_for or content_for.
  • Read More