简体   繁体   中英

How can I get the current Test with Split AB Testing

I started a test with the Split AB Testing gem, which renders two different templates like

@test = ab_test("test", "template_1", "template_2")

At this point @test gives me the desired template name. But I don't want to pass this parameter to the place I need it.

Is there a possibility to directly get the current test?

Under the Experiment Configuration heading in the documentation , it says you can do something like this:

<% ab_test("my_first_experiment") do |alternative, meta| %>
  <%= alternative %>
  <small><%= meta['text'] %></small>
<% end %>

You could wrap that in an if admin or something so only you see it.

I found out that the helper method

active_experiments()

provides all active experiments for the current user, which is exactly what I need. Thanks for your efforts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM