Created
May 9, 2013 10:42
-
-
Save scottwater/5546811 to your computer and use it in GitHub Desktop.
Quick and dirty A/B testing Rails views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for posting this. After playing around with Simple ABs and Abingo, I used this as the start of my own homegrown approach.