Class: Leva::DatasetsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/leva/datasets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createvoid

This method returns an undefined value.

POST /datasets



34
35
36
37
38
39
40
41
42
# File 'app/controllers/leva/datasets_controller.rb', line 34

def create
  @dataset = Dataset.new(dataset_params)

  if @dataset.save
    redirect_to @dataset, notice: 'Dataset was successfully created.'
  else
    render :new
  end
end

#destroyvoid

This method returns an undefined value.

DELETE /datasets/1



56
57
58
59
60
61
62
63
# File 'app/controllers/leva/datasets_controller.rb', line 56

def destroy
  if @dataset.dataset_records.any?
    redirect_to @dataset, alert: 'Cannot delete dataset with existing records.'
  else
    @dataset.destroy
    redirect_to datasets_url, notice: 'Dataset was successfully destroyed.'
  end
end

#editvoid

This method returns an undefined value.

GET /datasets/1/edit



28
29
30
# File 'app/controllers/leva/datasets_controller.rb', line 28

def edit
  # The @dataset is already set by the before_action
end

#indexvoid

This method returns an undefined value.

GET /datasets



9
10
11
# File 'app/controllers/leva/datasets_controller.rb', line 9

def index
  @datasets = Dataset.all
end

#newvoid

This method returns an undefined value.

GET /datasets/new



22
23
24
# File 'app/controllers/leva/datasets_controller.rb', line 22

def new
  @dataset = Dataset.new
end

#showvoid

This method returns an undefined value.

GET /datasets/1



15
16
17
18
# File 'app/controllers/leva/datasets_controller.rb', line 15

def show
  @experiments = @dataset.experiments
  @new_experiment = Experiment.new(dataset: @dataset)
end

#updatevoid

This method returns an undefined value.

PATCH/PUT /datasets/1



46
47
48
49
50
51
52
# File 'app/controllers/leva/datasets_controller.rb', line 46

def update
  if @dataset.update(dataset_params)
    redirect_to @dataset, notice: 'Dataset was successfully updated.'
  else
    render :edit
  end
end