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

By Peter Cooper / July 20, 2006


Other than being a new Rails-based site developed during the Summer of Rails, Graffletopia is a great resource for stencils for OmniGraffle, the OS X diagramming and charting app. One of the newest stencils on there is a “Ruby DB modelling” stencil that should help you lay out your models in a neat, easy to edit, way. The author notes:

This is a semi-complete version of a Ruby on Rails way to model a database. The table objects include a space to enter in the declarations that you are considering placing in your model files. I have included a list of reminders of the things that would go into the model declarations towards the right. Read More

By Peter Cooper / July 19, 2006


This one is for Mac users only..

Tim Burks has put together a guide on how to use your Apple infra-red remote from Ruby at And, as an aside, is a great resource if you’re interested in using the Cocoa framework from Ruby. Read More

By Peter Cooper / July 19, 2006


Shane Vitarana has launched a new Rails plugin called Rails Stats. It’s a graphical version of the rake stats statistics. It generates graphs showing information about your application, and is powered by Geoffrey Grosenbach’s great Gruff Graphs plugin.
Install like so:

script/plugin install

And then load /rails_stats on your running Rails application. More info here. Read More

By Peter Cooper / July 17, 2006


Mr. Guid is a Ruby GUI Debugger by ‘Mitchell’. It uses GTK+ so it’s cross platform (Windows, Linux, OS X) and it can even work remotely over a network. Otherwise, it has all the features that the standard Ruby debugger has, just in GUI form. Read More

By Peter Cooper / July 15, 2006

In the recent 19 Rails Tricks Most Rails Coders Don’t Know article, I recommended the use and development of engines to implement common functionality in Rails applications. I simply provided a link to the Rails Engines site and left it at that.

However, Joe France has put together a bumper tutorial on how to create a Rails Engine from start to finish, so now there’s no excuse not to give it a go! Joe holds your hand the whole way. Read More

By Peter Cooper / July 15, 2006

Bruce Williams tries to solve the problem of multiple parameter types in Rails. For example, an action may accept dates via a parameter, but dates may be supplied in many forms. A ‘date’ parameter might arrived as if from a date_select helper, or might even be typed in directly by a user, or be pulled from a database. Rather than use before_filters to check parameters and normalize them, Bruce suggests that it should be possible to add basic conversion tools to certain data types so that all data is normalized by the time it hits your controllers.

Bruce provides a simple example to demonstrate how two different types of date could be prenormalized:

ActionController::Base.add_param_type ‘date’ do |value|
case value
when String
when Hash['year']), Integer(value['month']), Integer(value['day']))

His ideas are available in a plugin called param_types. Read More

By Peter Cooper / July 14, 2006

Active Merchant is a payment processing library for Rails developed by the geniuses behind Rails powered e-commerce system, Shopify. It’s under active development with support for different payment processor gateways being added regularly. So far it supports:

  • Moneris
  • TrustCommerce
  • LinkPoint
  • Psigate

They want to integrate with WorldPay and ChronoPay next. The syntax for using Active Merchant and its descendent classes is ridiculously easy, so check it out (code examples viewable there). Read More

By Peter Cooper / July 13, 2006

There are many scenarios where you might want the same controller action / method in your Rails application to perform multiple functions. For example, a wizard with multiple steps or a single form with multiple-stage AJAX calls. What you want to do is provide a ‘context’ to the specific request and have the controller handle that in some different way.

Until now, one way to do this would be to use a parameter on the URL (e.g.: http://yourapp/post/show/1?stage=something_here) and then simply branch the logic based on the parameter. Bruce Williams saw an opportunity to make things a little better, and has developed in_context. Read More

By Peter Cooper / July 13, 2006

Action Messenger, by Trejkaz Xaoza, is a basic wrapper around Ruby’s xmpp4r Jabber library that makes Jabber instant messaging services directly available to Rails applications. (Jabber is an open, XML specification and framework for instant messaging. Google Talk uses it, for example.)

It’s still in its infancy and currently only supports basic message sending and receiving of messages, but with instant messaging rapidly merging into the plans of many Web applications, it’s a good start. If this sort of functionality is on your wishlist, check it out. Read More

By Peter Cooper / July 13, 2006


Perl is particularly well known for its one-liners from the command prompt, but Ruby is pretty adept at it too. David P Thomas has put together a collection of about 100 Ruby one-liners in a single text file for us all to enjoy. Read More

By Peter Cooper / July 12, 2006


The indefatigable Assaf Arkin has done it again by developing a new Ruby HTML scraping toolkit, scrAPI. Peter Szinek recently wrote a popular article about scraping from Ruby using Manic Miner, RubyfulSoup, REXML, and WWW::Mechanize, but none of these are as immediately useful as scrAPI.. so why?

scrAPI lets you scrape from HTML using CSS selectors. For example, here’s Assaf’s example that defines scraper objects that can scrape auctions from eBay:

ebay_auction = Scraper.define do
process "h3.ens>a", :description=>:text,
process "td.ebcPr>span", :price=>:text
process "div.ebPicture >a>img", :image=>"@src"

result :description, :url, :price, :image

ebay = Scraper.define do
array :auctions

process "table.ebItemlist tr.single",
:auctions => ebay_auction

result :auctions

Now that the objects are set up ready to scrape, you can put them into action like so: Read More

auctions = ebay.scrape(html)

# No.

By Peter Cooper / July 12, 2006

Install now with sudo gem install classroom

ClassRoom (RubyForge project) is a project to develop a distributed ‘class server’ powered by DRb that I have been working on. Let’s skip long explanations and jump into code. First, we’ll create a very basic “Dog” class with some basic features:

class Dog
attr_accessor :name

def self.count
@@count ||= 0

def initialize(options) = options[:name]
@@count ||= 0
@@count += 1

Next, we’ll create a program that can use Dog via ClassRoom:

require ‘rubygems’
require ‘classroom’

class_server =‘classroom://:2001′)

puts "There are #{Dog.count} dogs"
fido = => "Fido")
puts "There are #{Dog.count} dogs"
rufus = => "Rufus")
puts "There are #{Dog.count} dogs"
puts "fido’s name is #{}"

# => There are 0 dogs
# => There are 1 dogs
# => There are 2 dogs
# => fido’s name is Fido

Take care to notice that at no point is dog.rb actually included/’require’d. Read More

By Peter Cooper / July 11, 2006


Scaffolding is not meant to be a final solution for any application. It’s designed to provide ‘scaffolding’ for you to extend and improve. However, the developers of Trestle believe that the scaffolding could be improved significantly and have released their own version.

The trestle generator is an adaptation of the Rails scaffold generator. It produces scaffolding that’s more like production-quality code while maintaining all the rapid goodness you know and love about Rails.

The primary difference is that the HTTP verbs GET and POST are respected and used properly, as opposed to the system in Rails’ default scaffolding. This also allows trestles to be more succinct, with just four actions (index, new, edit, and destroy). Read More

By Peter Cooper / July 10, 2006

Geoffrey Grosenbach introduces the RaPT Plugin Manager for Rails, the answer to the problem of slow plugin installation. Installable as a gem (gem install rapt), RaPT caches the locations of different plugins so that installation is quick and easy. Future plans include developing a central plugin repository, auto-announcement of self-developed plugins, and automatic plugin upgrading. If you want the files direct, check out the Rubyforge project site for RaPT. Read More

By Peter Cooper / July 10, 2006

This library is so amazingly cool that it requires no descriptions beyond these code examples:

# => “running”

# => “two thousand and four”

“cow”.en.quantify( 20_432_123_000_000 )
# => “tens of trillions of cows”

# => “rubies”

Or what about?

allobjs = []
ObjectSpace::each_object {|obj| allobjs <<}

puts “The current Ruby objectspace contains: ” +
allobjs.en.conjunction( :generalize => true )
The current Ruby objectspace contains: thousands of Strings,
thousands of Arrays, hundreds of Hashes, hundreds of
Classes, many Regexps, a number of Ranges, a number of
Modules, several Floats, several Procs, several MatchDatas,
several Objects, several IOS, several Files, a Binding, a
NoMemoryError, a SystemStackError, a fatal, a ThreadGroup,
and a Thread

Go learn more. Read More

Recently Popular Posts