Skip to content

Instantly share code, notes, and snippets.

@scottwater
Created May 9, 2013 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottwater/5546811 to your computer and use it in GitHub Desktop.
Save scottwater/5546811 to your computer and use it in GitHub Desktop.
Quick and dirty A/B testing Rails views
module ABHelper
def choose_test(name, default_option, *options)
key = "#{name}_ab"
unless current_test = (params[key] || session[key] || cookies[key])
current_test = options[rand(options.count)]
end
current_test = default_option unless options.include?(current_test)
session[key] = cookies.permanent[key] = current_test
end
end
@kevintaylor
Copy link

Thanks for posting this. After playing around with Simple ABs and Abingo, I used this as the start of my own homegrown approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment