Sunday, February 26, 2006

Annotate Models Plugin

Rails model files contain no information on the tables they represent. This is a good thing in general, because it reduces duplication—add a column to a table, and there’s no configuration to update in the model.


However, when you’re writing code, it’s sometimes nice to be able to see just what attributes a model has.


Enter annotate models, a really trivial Rails plugin I hacked up in the plane back from the first No Fluffof the year. The plugin adds a comment block to the top of each model file, documenting the schema. If you update the schema, run it again and it updates the comment.


  # Schema as of Mon Feb 27 00:55:58 CST 2006 (schema version 7)
#
# id :integer(11) not null
# name :string(255)
# description :text
# image_location :string(255)
# price :float default(0.0)
# available_at :datetime
#

class Product < ActiveRecord::Base

validates_presence_of :name, :description
. . .

Install using:


  > script/plugin install http://repo.pragprog.com/svn/Public/plugins/annotate_models

and run with:


  > rake annotate_models

It only handles models directly under app/models. And, as it’s new, you’d be advised to back up your model files before running it.

Monday, February 6, 2006

Rails Guidebook is Full

I’m blown away!




The Rails Guidebook, our day of pre-conference training before RailsConf, is now officially full. Chad Fowler and Jay Zimmerman, who are handling logistics, twice negotiated to get bigger rooms, but we’ve had to draw the line at 150.


Yes, 150!


One hundred and fifty people are coming to learn about Rails, and have agreed to donate at least $40 to charity. Many folks have already donated a lot more. (And, remember, the three biggest donations get some VIP treatment.) I’m so, so proud of our community for making this happen. Ruby folks have always been nice to be around. To see them contributing back to the outside world like this just confirms it.


Thank you all.


(If you are coming, remember to get your donation in, and bring your receipt. See you there.)



Sunday, February 5, 2006

RailsConf and the Rails Guidebook

RailsConf in Chicago (June 22-25) promises to be an exciting affair. And it looks as if there’ll be a number of people coming who are fairly new to Rails.


So Mike and Nicole Clark and I were sitting down after a day of teaching a Rails Studio, and we came up with an idea. We’ll be running a one-day course before the conference. It is designed to bring newcomers to Rails up to speed, both with the framework and with Ruby.


We’re calling it the Rails Guidebook. Think of it as the difference between between turning up somewhere exotic knowing nothing about the language, customs, and places to visit, and turning up having spent a small amount of time reading a guide book. Hopefully, a day spent with us will make the rest of the conference more enjoyable (and informative).


We’re not charging for the Guidebook—it’s our way of saying “thank you” to the community. Instead, we’re asking folks to donate to charity before they come. Space is limited, so you might want to book early. (And, the top 3 contributors will get some perks…)