baby's first rails commit

programming ruby rails

today i fixed a thing in rails. rails has been near and dear to me since summer 2012, so it definitely feels like some sort of milestone to actually have code i wrote in it. more importantly, this file exist in the rails test suite now:

<%= 🎃 %>

welcome to october, rails.

this started as a misguided project which i made in an attempt to figure out and document a way to write templates that were easier to reuse than regular partials. it basically did nothing except provide three things:

my colleagues are smart, nice people that i trust. their feedback helps shape my ideas. i showed them this, telling them it’ll solve all of their problems. pan out to…

unenthusiatic response from crowd.

this type of feedback was is very useful. good ideas get support, bad ideas will be ignored, and great ones will upset some folks. this one was bad. Travis kindly pointed out that calling render from a helper doesn’t work with the default cache plumbing in rails. the bigger problem was that it’s clear no one wants some weird dependency, no kidding!

i wasn’t really thrilled about trying to persuade people to use my thing, and fixing the issues and being responsible for a separate project seemed at the opposite of my interests. it became obvious to me that i should improve the stuff i don’t like in rails.

how i expected this to go:

i thought making the fix would be difficult. that it would break all sorts of backwards compatibility things, and lead to a bunch of yak shaving and headaches. my patch would sit in a PR for months. i’d inadvertantly run an open source maintainer’s day. dhh might show up in front of my house in a racecar and scold me.

how it went:

the initial fix was simple, and ruby is super flexible in the way it let me write the fix for rails from the context of my own app, which i was comfortable in. i made it available as a gem and could use it in my existing apps immediately. moving the fix into rails was easy.

now to create a pull request. i predicted it’d sit there and rot, and i’d have to rebase it every few days, test it, solicit someone to come tell me why they don’t like it. a whole 25 minutes after opening the PR, Matthew Draper had reviewed my work and offered helpful advice about where i could look to improve my patch. huh. shortly after Kasper Timm Hansen dropped in, clearly having read all the code and thought about it, and dropped some tips. then Jon Moss categorized my patch and restarted the CI servers. Matthew ended up diving into the ruby language parser, and writing a regex that matches valid ruby local variables names. this took my patch from a blacklist to a whitelist, and much more generally useful. i opened the PR on friday afternoon, and now it’s sunday morning and the thing is merged and backported.

so basically, i had a problem that was affecting me, and wrote a small amount of code to resolve it. then three strangers came in, on a friday night and over the weekend, looked over my code gave me insightful feedback, several times over. they guided me to improve it to a point where it’s much more comprehensive fix than my initial contribution.

i guess this what happens in rails’ repo? maybe open source elsewhere? i really thought it was supposed to be more like Linus Torvalds shaming you on a 10,000 person mailing list of your peers. make open source great again amirite.

it’s sad to think that the github issues that get the most attention are often some depressing trainwreck. the rails pull request page appears to be a staggering amount generosity and kindness. i would encourage anyone to share your patches there, you won’t regret it.

anyway, now no one will see a confusing error in their rails templates, and i can use templates the way i like to. cool! thanks Matthew, Kasper, and Jon. I really appreciate what y’all do, and hope to pay it forward.


* i learned that render does take blocks now. previously you had to write render layout: 'foo' do ... which sucked. it’s cool that people swoop in and fix this stuff, and that people take the time to get it into rails for everybody to enjoy



home