A/Bingo in Rails 3.1

To add A/Bingo to a Rails 3.1 you can mostly follow the (Rails 2) install docs, but you’ll might run into some slight differences.

For a full set of instructions to get up and running, head to Andy Atkinson’s post Getting started with A/Bingo and Rails 3. I’ll just cover some extra tidbits here.

Using Redis as the data store

A/Bingo uses a cache layer for mapping sessions to experiment participation. Out of the box it will just use whatever Rails is already using for caching. That’s probably ok unless your app is hosted on multiple web servers, then you’ll need to bring up some persistent, shared cache like memcache.

In our setup, we already had redis for another application so I just piggybacked on that.

Gemfile

To setup A/Bingo to use redis, first edit your Gemfile and run bundle install:

gem 'redis'
gem 'redis-store', '1.0.0.rc1'

setup A/Bingo per environment

Edit your environment files and setup the redis configuration to point to your servers.

# Abingo options
# expires_in: prevents flooding redis and "consuming all memory"
redis_server = 'redis://production.redis.server:6379/1/broadband_com'
Abingo.options[:expires_in] = 1.hour
Abingo.cache = ActiveSupport::Cache::RedisStore.new redis_server

And there you go, A/Bingo in Rails 3.1 using redis for the caching storage. In actual use you’ll want to move the redis server specification to a yml file keyed by rails environment.

Bonus Round: authenticating A/Bingo access using CMS

If you’re using Comfortable Mexican Sofa then you’re 98% of the way there. Just change your dashboard controller to inherit from CmsAdmin::BaseController.

class AbingoDashboardController < CmsAdmin::BaseController

Done!