Module: Vanity::Rails::Dashboard

Defined in:
lib/vanity/frameworks/rails.rb

Overview

Step 1: Add a new resource in config/routes.rb:

  map.vanity "/vanity/:action/:id", :controller=>:vanity

Step 2: Create a new experiments controller:

  class VanityController < ApplicationController
    include Vanity::Rails::Dashboard
  end

Step 3: Open your browser to localhost:3000/vanity

Instance Method Summary (collapse)

Instance Method Details

- (Object) add_participant



255
256
257
258
259
260
261
262
263
# File 'lib/vanity/frameworks/rails.rb', line 255

def add_participant
	if params[:e].nil? || params[:e].empty?
	  render :status => 404, :nothing => true
	  return
	end
  exp = Vanity.playground.experiment(params[:e])
  exp.chooses(exp.alternatives[params[:a].to_i].value)
  render :status => 200, :nothing => true
end

- (Object) chooses



249
250
251
252
253
# File 'lib/vanity/frameworks/rails.rb', line 249

def chooses
  exp = Vanity.playground.experiment(params[:e])
  exp.chooses(exp.alternatives[params[:a].to_i].value)
  render :file=>Vanity.template("_experiment"), :locals=>{:experiment=>exp}
end

- (Object) index



245
246
247
# File 'lib/vanity/frameworks/rails.rb', line 245

def index
  render :file=>Vanity.template("_report"), :content_type=>Mime::HTML, :layout=>false
end