My first Ruby on Rails patch

— April 10, 2006 at 19:15 PDT

My first Ruby on Rails patch was just committed to the trunk. I'm now officially a Rails contributor. Yay me!

Changeset 4206 is my patch for enhancing the :extend option to allow multiple named extension modules on associations.

I've wanted this ever since I started using extension modules. I quickly ran into a situation where I wanted to use two named modules for the same association. Here's the hacked way of doing that:

has_many :friends, do
  include PeopleExtension
  include FriendsExtension

The change in my patch allows this more compact syntax:

has_many :friends, :extend => [PeopleExtension, FriendsExtension]

So much better!

This patch was a bit of a trial run for me to learn the whole process for putting a patch together. The actual change was only one line of Ruby code (but don't forget the 20 or so lines of tests and documentation!). Now that I seem to have the process down I can think about doing something a bit bigger.

As I get more confident in the process I'll write up a better description of how to contribute changes to Rails. The description on the Rails Trac is pretty bare-bones and takes a bit of muddling through if you've never worked on an open source project before.

4 commentspatch, rails

  1. UncleD2006-04-11 01:28:30

    Congratulations! We can use more contributions like these, makes the code look elegant :)

  2. Gregg2006-04-11 07:39:00

    Congrats! Excellent work!!

  3. Jerry2006-05-03 07:32:23

    excellent -- cool that you're a contributor and big ups for you blog, I have used it as a reference tool a number of times.

  4. Labrat2006-08-19 15:45:07

    If you ever get around to writing that how to submit a patch to rails article, you'll have one very eager reader right here! (Small overview of the framework, preparing and running tests (how railties fits in), etc.)

Sorry, comments for this article are closed.