Ruby Stuff

Babysteps to Open Source

I’ve often lamented my lack of contribution to the open source community. It seems that deadlines for feature work have always gotten in the way of things. I’ve been trying to fix this by proactively looking for opportunities to make problems I’ve solved shareable. Last week I was able to make my first gem.


We recently pushed up a change to our sandbox that took us from Rails 2.3.5 to 2.3.18.

A few days after doing so, we got reports of some seemingly incomplete data that would need to be populated. After investigating, I finally was able to find the bug: Rails 2.3.9 and up doesn’t handle find_or_create_by hash arguments as expected in 2.3.8 and below.


Using a gem is much more preferable approach than patching ActiveRecord, so we did that: DetectOrCreate

Now, not only can we find a record and create if it doesn’t exist, but we can also optionally update any existing records.

It’s not a big or flashy gem, but it does solve a problem, and it’s out there (with specs!). That’s a baby step.

gem install detect_or_create