Class: SplitCat::ExperimentsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/split_cat/experiments_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /experiments



32
33
34
35
36
37
38
39
40
# File 'app/controllers/split_cat/experiments_controller.rb', line 32

def create
  @experiment = Experiment.new(experiment_params)

  if @experiment.save
    redirect_to @experiment, notice: 'Experiment was successfully created.'
  else
    render action: 'new'
  end
end

#destroyObject

DELETE /experiments/1



52
53
54
55
# File 'app/controllers/split_cat/experiments_controller.rb', line 52

def destroy
  @experiment.destroy
  redirect_to experiments_url, notice: 'Experiment was successfully destroyed.'
end

#editObject

GET /experiments/1/edit



28
29
# File 'app/controllers/split_cat/experiments_controller.rb', line 28

def edit
end

#indexObject

GET /experiments



6
7
8
9
10
11
12
# File 'app/controllers/split_cat/experiments_controller.rb', line 6

def index
  @name = params[ :name ]
  @active = ( params[ :active ] == '1' )

  @experiments = Experiment.order( 'id desc' )
  @experiments = @experiments.where( 'name like ?', '%' + @name + '%') if @name
end

#newObject

GET /experiments/new



23
24
25
# File 'app/controllers/split_cat/experiments_controller.rb', line 23

def new
  @experiment = Experiment.new
end

#showObject

GET /experiments/1



15
16
17
18
19
20
# File 'app/controllers/split_cat/experiments_controller.rb', line 15

def show
  respond_to do |format|
    format.html
    format.csv { render :text => @experiment.to_csv, :content_type => 'text/csv' }
  end
end

#updateObject

PATCH/PUT /experiments/1



43
44
45
46
47
48
49
# File 'app/controllers/split_cat/experiments_controller.rb', line 43

def update
  if @experiment.update(experiment_params)
    redirect_to @experiment, notice: 'Experiment was successfully updated.'
  else
    render action: 'edit'
  end
end