Skip to content
ab testing for rails
Find file
Latest commit ed3a399 @paulmars change date
Failed to load latest commit information.
generators/ab_migration update install directions, remove memcache stuff for now
lib show stats, and percent in model
tasks empty
test empty
README change date
Rakefile empty
init.rb testing
install.rb add migrationa nd view code
uninstall.rb empty



Ab testing is 7 minutes.  Not 6, not 5, 7!

Tested in rails 2.3.2

go to your rails app directory
  ./script/plugin install git://

Setup the database to store your info

  ruby script/generate ab_migration
  rake db:migrate

Include Code
add these lines to these files

  module ApplicationHelper
    include AbViewHelper

  class ApplicationController < ActionController::Base
    include SevenMinuteAbs
    before_filter :ab_click_count

Use it!
Test if orange or blue gets more clicks

"linkcolor" -> name of your test
2 -> number of different versions you have (else statement)

make sure to include 'test.stub' in any urls, otherwise clicks won't be counted! 

  <% ab_test("linkcolor", 2) do |test,version|%>
    <% if version == 0 %>
      <%= link_to "Blue version", url_for(:ab => test.stub), {:style => "color:blue"} %>
    <% elsif version == 1 %>
      <%= link_to "Orange version", url_for(:ab => test.stub), {:style => "color:orange"} %>
    <% end %>
  <% end %>

See Stats
A quick way to see your stats.  You want the highest % possible to be your main choice!

<% Ab.find(:all).each do |ab| %>
  <div class="ab-result">
      name:<%= ab.testname %> v:<%= ab.version %> <%= ab.percent_clicked %>%     <%= ab.display_count %> <%= ab.click_count %> <%= ab.stub %> <%= ab.created_at %>
<% end %>

Copyright (c) 2009 Paul McKellar, released under the MIT license
Something went wrong with that request. Please try again.