https://github.com/andrew/split
关于 AB 测试的一个 gem,一个 controller 代码如下:
def show
@ab_style = ab_test("show_click", "origin", "testA")
end
def split_finish
finished("show_click", :reset => false)
render :nothing => true
end
官方描述 finished 方法中的 reset Reset after completion When a user completes a test their session is reset so that they may start the test again in the future.
To stop this behaviour you can pass the following option to the finished method:
finished('experiment_name', :reset => false) The user will then always see the alternative they started with.
但是每当我请求 split_finish 以后,再次请求 show,又会获得新的值。
split 里面的 ab_test 方法会 set 一个 user session,show action 以后:
{"session":{"session_id":"....","_csrf_token":"....","split":{"show_click:6":"origin"},}}
finished 以后:
{"session":{"session_id":"....","_csrf_token":".....","split":{},}}