18

I have been inspired by how both Flickr and Disqus use feature switches. They both blogged about them and how they work on both of their development blogs.

I was just wondering if there was a Ruby gem i'm missing or if anyone knows of a way to do this in Ruby? If there isn't anything, I'd hope to make my own and release it out in the wild. But I just wanted to ask here first because I haven't been able to find anything remotely similar to what both Flickr and Disqus achieve.

Garrett
  • 7,830
  • 2
  • 41
  • 42

5 Answers5

13

Check rollout if you're already using Redis.

Adrian Pacala
  • 1,011
  • 1
  • 8
  • 12
  • 2
    The Readme notes that 2.x no longer depends on Redis. – alxndr Nov 11 '12 at 17:09
  • The following post will explain how to use another data store for rollout. http://americastestkitchen.github.io/ruby/rollout/2015/02/06/postgres-store-for-rollout-gem/ – Sagar Ranglani May 11 '15 at 15:55
4

I recently (9 Oct 14) took a look at the available gems - 9+ in various states of maintenance - and decided to go with Flipper. Rollout is also worth a look.

If you are looking to roll your own the source code for Rollout is only 200 lines and a good place to start. https://github.com/FetLife/rollout/blob/master/lib/rollout.rb

This railscast also has a barebones example http://railscasts.com/episodes/315-rollout-and-degrade

andorov
  • 4,197
  • 3
  • 39
  • 52
2

Also highly recommend the pattern. No gems that I know of, but it's pretty easy to do. One tip: include the ability to auto-set the initial state to either on or off:

feature_flag('third_party_tool', :default => true) do
    ... # this is on by default
end

This will save you headaches at deployment time.

seriousken
  • 179
  • 8
2

Here's a few more:

Empact
  • 462
  • 6
  • 6
  • 3
    Those repos haven't been touched in two years (as of Nov 2012) -- are they still dependable? – alxndr Nov 11 '12 at 17:10
1

I tried all the flipper gems available now (March 2015) and chose the ruby_flipper

Yes, it is older than others, but it allows you to use blocks and arguments to calculate feature state, and it is damn simple.

It does not require redis, any database or anything else.

For multi-server setup I use ENV variables. It's actually possible to use anything since it does not limit you (like the other options here do).

The only thing I don't like is that ruby_flipper pollutes Object with its methods, but that is easy to solve.

To summarize: if you need a lightweight, configurable and not limited solution, I vote for this simple gem.

Others are good in some specific area, this one is good to start with.

Another good candidate is rollout mentioned in accepted answer.

hcarver
  • 7,126
  • 4
  • 41
  • 67
Alexander Paramonov
  • 1,441
  • 14
  • 24