Posted in Rails, Ruby on February 12th, 2007 9 Comments »
Variations on the Decorator Design Pattern in Ruby have already been discussed in several places. For my special purpose, none of these approaches works. The common problem with a decorator based on delegation is the lost sense of self. Method calls of the decorated object to itself are not routed through the decorator, therefore remain [...]
Posted in Rails, Testing on February 6th, 2007 No Comments »
Coda Hale has given the intersection of the Rails and web standards communities a very nice plugin for keeping your markup clean. It is aptly, if slightly pretentiously, named Responsible Markup. But let’s be honest, do you really want to spend much time on writing tests for your markup? After all, it’s taking long enough [...]
Posted in Rails on February 3rd, 2007 8 Comments »
Ever wanted to iterate over a huge number of objects and found that find(:all) doesn’t cut it? Then this plugin might be for you. Install it with $ script/plugin install svn://rubyforge.org/var/svn/ar-enumerable/ar_enumerable/trunk First, a note of caution. This plugin has not seen much practical use yet, in its current state it is only slightly above a [...]
Posted in JavaScript, Rails on January 31st, 2007 9 Comments »
See the end of this post for an important update. Standard Rails auto-completion is geared toward completing a single value entered in a text field. For most cases this is exactly what’s needed, but there is one prominent case that is different: auto-completion of tags. If something can have a tag at all, it’s part [...]
Posted in Rails, Ruby, Tools on January 1st, 2007 No Comments »
I’m using Eclipse with RadRails to edit my Ruby and Rails code (and, yes, I’ve used it for Java, way back when). Inside Eclipse the various text editors offer so-called templates. These are snippets of common code with placeholders for variable bits. Type in the abbreviation for a template, then type Ctrl-Space and the abbreviation [...]
Posted in JavaScript, Rails, Ruby on December 15th, 2006 21 Comments »
Ruby on Rails already does a good job of specifying almost declaratively what conditions objects must meet to be considered valid–that is, how they are validated. Thus, in order to make sure that a Person’s last_name attribute does not exceed 100 characters, you would write something like this class Person < ActiveRecord::Base validates_length_of :last_name, :maximum [...]