The best Ruby on Rails plugins and gems

Posted by peter on May 04, 2007

I know its geeky, but lets face it, if you're building social applications you've got to consider using Rails. Everything we build we build using Rails -- including this very website. So here, in no particular order atall are a few of my favorite plugins for Ruby on Rails.

ZenTest If you’re not testing you’re wasting valuable time. If you’re testing but not using ZenTest you’re still wasting valuable time. In particular, autotest (a part of the ZenTest gem) is a brilliantly simple approach to reducing -- as much as I’ve ever seen done -- the gap between test and code. You run it and it tests your code whenever and as soon as you change it. Rad rad rad.

Piston You’ve got plugins or you’re working on the edge and you want that 3rd party code to be up-to-date, right? How annoying is it to re-install that stuff and re-import it into your source tree? Piston acts as an interface between your source tree and the source trees of your 3rd party applications and plugins. piston update and you’re source suddenly has an up-to-date copy, committed and ready to go.

ferret Hello full text search! This port of the popular, well-designed Java search system Lucene, is an easy way to effectively index the plain text in your models. I find it to be a better fit for most of my projects than MYSQL full text indexing because it exists separately from the database and is explicitly designed for text search.

capistrano If you’re not using this deployment management tool you’re wasting precious time! It's simple to setup and easy to use. Let’s see, let me go to my rails root. I’ll enter cap deploy. 1, 2, 3, 4, 5 seconds later and I have the latest version of my source installed, my application servers have been reset, the database migrated, AND I’ve got a complete copy of the last deploy to rollback too if need be. Oh and it resets my backgroundrb (see below) processes plus a bunch of other custom stuff I wrote. Rad Rad Rad.

backgroundrb In the Java world this would be called Quartz. In the ruby world its just as indispensable. Perhaps not when you’re starting out, but pretty early on you can be sure you’ll need to run, on an automated basis, various scripts. I use it to manage the sending of emails so that I don’t tie up my mongrel application processes. I also use it to do database and session cleanup.

RedHill Consulting Plugins, et al These guys offer a series of plugins so simple and useful they feel like they ought to have been a part of rails itself. foreign_key_migrations is a plugin that automagically creates indexes in your database based on your database schema. A users table which references a article_id will automatically get an foreign key index to the articles table. Rad rad rad. (This can create some hassle with your test fixtures though, since you won’t be able to insert data with bad references.)

Exception Notification This plugin is a life saver! And pretty annoying too! It makes it easy to get an email detailing what happened when something goes wrong with your rails app.

Routing Navigator This handy plugin can really help with the transition from your old rails app to your new RESTful application by displaying information about all the routes and named route methods being generated by your routes.rb

Simply Helpful Written by DHH himself, this set of helpers and methods simplifies a lot of common tasks. polymorphic_url(object) generates the correct URL for any model which has coverage in your routes.rb. dom_id(object) will create a class + id based identifier which you can reference in your RJS scripts and HTML to ensure everything gets wired up correctly. Handy!

Paginating Find I’ve just started using this one but it looks great. Instead of using this weird extra pagination method, paginating find adds a few simple options to the built in find command to more efficiently allow you to select out pages of models.

File Column Though not updated in a while, this plugin makes it super easy to add files to model objects. In particular, it handles images very well and has great integration with rmagick to automatically do things like image resizing and version management.

Validates Url A little something I wrote, this guy does simple validation on model fields to check that they have a certain protocol and are correctly formed server/path strings.

how unobtrusive javascript libraries work

Posted by peter on February 05, 2007

An easy to understand, fascinating read on how a lot of the so-called unobtrusive javascript libraries work with different browsers. From the article:

The goal of unobtrusive JavaScript programming it to separate the JavaScript behavior from from the HTML content and is analogous to the goal of unobtrusive CSS design to separate the CSS presentation from the HTML content. Separation of presentation and content has been possible for years but there is one wrinkle standing in the way of completely separating the behavior. This article is about previously suggested techniques to enable this separation, their problems and a new option that combines the strengths of the current techniques with an extra bonus into a new robust solution.

Read more at Peter’s Blog