Class: CompletionKit::DatasetsController

Inherits:
ApplicationController show all
Includes:
TagFiltering
Defined in:
app/controllers/completion_kit/datasets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
# File 'app/controllers/completion_kit/datasets_controller.rb', line 21

def create
  @dataset = Dataset.new(dataset_params)

  if @dataset.save
    redirect_to datasets_path, notice: "Dataset was successfully created."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



39
40
41
42
# File 'app/controllers/completion_kit/datasets_controller.rb', line 39

def destroy
  @dataset.destroy
  redirect_to datasets_path, notice: "Dataset was successfully destroyed."
end

#editObject



18
19
# File 'app/controllers/completion_kit/datasets_controller.rb', line 18

def edit
end

#indexObject



6
7
8
# File 'app/controllers/completion_kit/datasets_controller.rb', line 6

def index
  @datasets = apply_tag_filter(Dataset.includes(:runs, :tags).order(created_at: :desc))
end

#newObject



14
15
16
# File 'app/controllers/completion_kit/datasets_controller.rb', line 14

def new
  @dataset = Dataset.new
end

#showObject



10
11
12
# File 'app/controllers/completion_kit/datasets_controller.rb', line 10

def show
  @runs = @dataset.runs.includes(:prompt, :responses).order(created_at: :desc)
end

#updateObject



31
32
33
34
35
36
37
# File 'app/controllers/completion_kit/datasets_controller.rb', line 31

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