Some writing by Trek

& archive, twitter, github

Has Many, with Precedence

Every so often I have a has_many ActiveRecord relationship with a twist: one (and only one) of the many possible related items is special in some way and I want to be get and set it like other associations. Imagine a Customer has several phone numbers, but only one is their primary contact number.

Multiparameter assignment and attr_accessor

I’ve needed multiparamter assignment on non-persisted attributes for a few projects (usually on for Date and Time objects). Typically, I cheat and send separate attribute and have a before_validation callback to combine them into a date. I finally sat down and sussed out how to do it properly...

Format Parsing in Javascript

Riff is a a recent spin-off project from Jesse Sielaff’s work to bring a Ruby-like language interpreter to the browser. Riff is a plugin for Racc (a LARL(1) parser generator for Ruby). Riff extends the output generation portions of Racc and writes javascript instead of Ruby. If you’re familiar with LALR grammars this should add a handy tool to your javascript arsenal...

Automating iTunes Gift Cards

I’m finishing up a project for the University of Michigan School of Public Health that involves using iTunes Gift Cards as a participant incentive. They’ve pre-bought about $20,000 of Gift Cards and given me the ids. We could just have participants copy/paste their code into iTunes, but I wanted to create a smooth user experience for redeeming.

Rails Foundations Workshops - Winter 2010

If you’re in South East Michigan and serious about learning (or better understanding) Rails our upcoming Rails Foundations workshop series is for you.

This season, we're trying something new: name your own price workshops