I'm trying to install Vanity A/B Testing in my Rails App, but I can't even get the example from the GitHub page working. I've generated the vanity models and run the migrations and made the experiment files, but as soon as I include a test like
<%= ab_test :price_options %>
the program throws an error:
invalid value for Integer(): "{:conditions=>{:experiment_id=>\"price_options\""
In my controllers/application_controller.rb I have just:
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
use_vanity
end
I didn't include a user identifier because I haven't built one into this app yet, but the Vanity docs say that if no argument is supplied Vanity will just use cookies instead, so that shouldn't be an issue. If anyone has any clue why this cryptic error is being thrown, I would be very appreciative!
Edit: I should add that I actually started a new rails app from scratch just to try and debug this. Literally all I did was start an app and install vanity following the readme instructions and I got this same error. This has happened on two different machines as well, so I suspect it's something obvious that I'm missing, but I can't be sure (else I wouldn't be here!).
EDIT: I've since decided to use the Split gem instead, and am having no troubles with it.
This error is thrown because the current release version of Vanity uses the deprecated Rails find(:first) method, specifically:
This no longer works with Rails 4.1 but is fixed in the master branch of Vanity, so you can get round this in your Rails 4.1 app by adding:
to your Gemfile.