You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The steps in the instructions in the "outside-of-a-web-session" are not working
I cloned the example project https://github.com/splitrb/split-rails-example
I have redis running and the sample page and dashboard work as expected.
Hopping into a rails console for that project and following the steps from #outside-of-a-web-session
it fails on trial.choose!
with error NoMethodError (undefined method `cleanup_old_experiments!' for nil:NilClass)
Looking at the code, it assumes that a Split::User is loaded.
It makes sense that some type of context and unique ID would need to be passed along when creating the new Trial instance, but just following the steps listed does not flow as expected. (unless there is something about an adapter that is required to make it work)
#- create a new experiment
experiment = Split::ExperimentCatalog.find_or_create('color', 'red', 'blue')
#- create a new trial
trial = Split::Trial.new(:experiment => experiment)
#- run trial
trial.choose! # << this will fail
The text was updated successfully, but these errors were encountered:
The key part is to pass a user reference (and know how an existing user is identified)
key = "user-#{user.id}"
ab_user = Split::User.new(nil, Split::Persistence::RedisAdapter.new(nil, key))
trial = Split::Trial.new(user: ab_user, experiment: experiment) # << passing in the ab_user is the key
trial.choose! # << now this doesn't fail
The readme can just be updated with the part about initing a user reference to pass to Trial.new, then trial.choose! won't fail
The steps in the instructions in the "outside-of-a-web-session" are not working
I cloned the example project
https://github.com/splitrb/split-rails-example
I have redis running and the sample page and dashboard work as expected.
Hopping into a rails console for that project and following the steps from
#outside-of-a-web-session
it fails on
trial.choose!
with error
NoMethodError (undefined method `cleanup_old_experiments!' for nil:NilClass)
Looking at the code, it assumes that a Split::User is loaded.
It makes sense that some type of context and unique ID would need to be passed along when creating the new Trial instance, but just following the steps listed does not flow as expected. (unless there is something about an adapter that is required to make it work)
To reproduce:
git clone https://github.com/splitrb/split-rails-example
cd split-rails-example
bundle
(start redis if needed)
rails c
#- create a new experiment
experiment = Split::ExperimentCatalog.find_or_create('color', 'red', 'blue')
#- create a new trial
trial = Split::Trial.new(:experiment => experiment)
#- run trial
trial.choose! # << this will fail
The text was updated successfully, but these errors were encountered: