I absolutely love continuous deployment and similarly can’t stand
long-running feature branches. The rub is features that actually take a
bit of work to get finished up. I’m a big fan of deploying the least
possible functionality and iterating from there. Along those lines, I
have always liked the idea behind James Golick’s rollout
gem. Deploy your code and new
features regularly, but decouple deployment and feature availability.
And, to take it a step further, don’t limit yourself to deploying a
feature all or nothing. Consider release to a select group.
I can’t find the reference, but GitHub uses flags to release features.
They have something akin to an “employees” switch that allows them to
use features before the rest of us. Brilliant.
While I like rollout, I wasn’t ready to add another gem to our repo. I
had a feature I want to rollout in stages, in case anything goes wrong
or has unexpected consequences. So I whipped up a simple class using on
of my favorite toys, “Rails.cache”.
Now, I can wrap functionality in the view like so:
And from the console, I can change the on/off flags (since the feature
is off by default in production, and on for other environments) for all
members of the User class:
Or turn it on for a single user:
Of course, you could get crafty at the console and activate a random
group of users, etc.
It’s all dirt simple, but gets the job done. Once the feature is in full
usage, I’ll go back and remove the #active? checks.