
Tim Hunter, of RMagick, the Ruby Image/GraphicsMagick library, has put together a cool tutorial about how to use RMagick to produce Web 2.0 style graphics, as shown above. It’s pretty in-depth. Read More
RubyNode is an interesting Ruby library that spits out semantic representations of code much in the same way the inspect method does with data. Here’s a demo: Read More
>> def plus_1(x)
>> x + 1
>> end
=> nil
>> pp method(:plus_1).body_node.transform
[:scope,
{:next=>
[:block,
[[:args, {:rest=>-1, :cnt=>1, :opt=>false}],
[:call,
{:args=>[:array, [[:lit, {:lit=>1}]]],
:mid=>:+,
:recv=>[:lvar, {:vid=>:x, :cnt=>2}]}]]],
:rval=>[:cref, {:next=>false, :clss=>Object}],
:tbl=>[:x]}]
Many coders will reach a situation where developing a C extension makes sense, whether for doing ‘heavy lifting’, diving into assembly language, interfacing with other C code, etc. Luckily, developing a basic Ruby extension in C is easy.
Note: This article assumes you are using a UNIX of some sort (this was all tested on OS X) and that you have Ruby installed properly (from source, ideally, so you have ruby.h available). If not, you may be stuck.
First, create a directory called MyTest (or whatever you want your extension to be called) and in there create two files, extconf.rb and MyTest.c (if you want to download pre-written sources, they’re in this tar file). Read More

Ruby Discoveries and Idioms is a new(ish) Ruby blog that’s full of interesting code featuring the author’s Ruby ‘discoveries’ and lots of Ruby idioms. If hacking around with classes is your idea of fun, it’s a great blog. Read More
mly from caboo.se looks at how to quickly protect certain controller actions from GET requests in Rails, and presents a couple of useful test helpers to make testing for POST vs GET compliance simple. His code lets you then do a simple test like so:
def test_update__with_get
assert_method_not_allowed(:update, {:good => :post, :bad => :get})
end
This test ensures that ‘update’ will only accept a POST request and not a GET. Read More

Above: Courtenay’s team hard at work.
This year’s Rails Day has kicked off. 24 hours of coding madness where you start with absolutely nothing (except a choice of some JavaScript libraries, Rails, and RubyGems) and build an application to wow the celebrity judges. Winners get tons of prizes from a MacBook Pro, a day at an Adaptive Path workshop, through to Web hosting and other services.
If you want to spectate, there’s a Campfire chatroom for the purpose, as well as graphs and other information on the commits and svn activity of the participants. The repositories are usually opened up sometime after the contest has finished, so there’ll be lots of great code to check out. Read More
The guys over at Fingertips present an article entitled ‘excellent and pragmatic proposal for easier Unicode support in Rails‘. Julian ‘Julik’ Tarkhanov has developed a proxy class for String that tweaks all of the methods to work properly with Unicode. You can then use code like this:
text.chars.length > length ? text.chars[0...l] + truncate_string : text
chars provides the proxy object from the text string. You can also use code like text.u.length as chars is aliased to u too.
They want to see it accepted as a patch to Rails, although I’m personally more interested in seeing this become a gem and be available in Ruby generally. Read More

CodeRay is a totally new syntax highlighting library written in Ruby. It deals with Ruby, C, Delphi, HTML, RHTML, and Nitro-XHTML out of the box, with plans to support YAML, SQL, Python, Perl, PHP, and Java. It’s quite customizable and easy to use, as seen in the code in the image above. Nice work! Read More
Mauricio Fernandez reports that the next minor version of Ruby, Ruby 1.8.5, is due for release in mid August to coincide with the Japanese holiday of Obon. Ruby releases are usually tied to holiday periods, most notably Christmas for 1.8.3 and 1.8.4.
For the more adventurous, the initial preview release of 1.8.5 is coming by the end of June, with other preview releases in July and August. If Japanese is your thing, there’s more info here. Read More

Several months ago there was a competition to redesign the official Ruby homepage at ruby-lang.org. A winning design was chosen, and why said the work on implementing it would begin shortly thereafter.
It hasn’t gone live for real yet, but you can preview the new design in the flesh at http://new.ruby-lang.org/en/ Read More
Derek Haynes laments:
Auto-Complete is a great tool when it provides possible results BEFORE you finish typing. Unfortunately, using Rails’s included AJAX helpers to query the database as you type often results in a large delay before matches are returned.
There have been small hacks from several people to help resolve this, but Derek presents a simple local_auto_complete_field helper (with source to use right away) that lets you specify some pre-fetched results for the autocompleter to use right away. Read More
I’ve noticed many readers are using del.icio.us, so this should come in handy. Someone has developed a Ruby script that uses the del.icio.us API to download all of your links, and then uses SQLite to put them into a local database, whereupon you can do whatever you like with them. I just gave it a try and it works well.
It lacks some spit and polish though, and will complain if you run it more than once a day (as it attempts to recreate the tables on the same database). While you can run it daily, it uses a new database for each day, which might also not be so great. Read More
Peter Szinek has announced he’s going to write a series of articles on ‘screen scraping’ with Ruby (more accurately, extracting data from Web pages and other online sources) and has released the first article entitled “Data Extraction for Web 2.0: Screen scraping in Ruby/Rails“. He covers four basic scraping techniques, first using regular expressions, then HTree and REXML, then RubyfulSoup, and finally WWW::Mechanize. If you need to process shaky HTML sources from Ruby, read on.
The font used on his blog may seem a little painful to some readers, but he covers these main libraries and techniques pretty well. Read More
KRJS is an extension to Rails views by Chew Choon Keat that helps provide a radically different mechanism for handling AJAX and RJS. He calls it “RJS without messing the views.”
Rather than use remote_form_for and link_to_remote, for example, you can create specifically named actions on your controller that use RJS to perform the relevant actions upon regular code, rather than clog your views up with JavaScript and AJAX snippets. For example:
<%= form_tag({:action => ‘submit’}, {:id => ‘form’}) %>
<%= text_field ‘account’, ‘login’, :id => ‘account-new-login’ %>
<%= submit_tag ‘Login’ %>
<%= end_form_tag %>
This code looks like a normal form, but with KRJS, when the form is submitted the on_form_submit action is called on the controller via AJAX. Read More
Aidan Finn, a freelance Ruby on Rails developer in Ireland, has developed a quick guide to creating your own generators in Rails. Code generators in Rails are useful when you have similar patterns between controller in various projects, but aren’t ready to jump into creating a Rails Engine or plugin, or where such wouldn’t be relevant. Read More
